[FL-1505] Add RAW format (#576)
* Add RAW format * F5 stubs for build to pass * Fix saving decoded signal error * Irda: set ISR before starting timer, remove explicit NVIC configuration Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
#include "file_reader/file_reader.hpp"
|
||||
#include <file_reader.h>
|
||||
|
||||
std::string FileReader::getline(File* file) {
|
||||
std::string str;
|
||||
size_t newline_index = 0;
|
||||
bool found_eol = false;
|
||||
bool max_length_exceeded = false;
|
||||
|
||||
while(1) {
|
||||
if(file_buf_cnt > 0) {
|
||||
@@ -20,7 +21,12 @@ std::string FileReader::getline(File* file) {
|
||||
furi_assert(0);
|
||||
}
|
||||
|
||||
str.append(file_buf, end_index);
|
||||
if (max_line_length && (str.size() + end_index > max_line_length))
|
||||
max_length_exceeded = true;
|
||||
|
||||
if (!max_length_exceeded)
|
||||
str.append(file_buf, end_index);
|
||||
|
||||
memmove(file_buf, &file_buf[end_index], file_buf_cnt - end_index);
|
||||
file_buf_cnt = file_buf_cnt - end_index;
|
||||
if(found_eol) break;
|
||||
@@ -33,6 +39,9 @@ std::string FileReader::getline(File* file) {
|
||||
}
|
||||
}
|
||||
|
||||
if (max_length_exceeded)
|
||||
str.clear();
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
|
@@ -8,6 +8,7 @@ class FileReader {
|
||||
private:
|
||||
char file_buf[48];
|
||||
size_t file_buf_cnt = 0;
|
||||
size_t max_line_length = 0;
|
||||
SdCard_Api* sd_ex_api;
|
||||
FS_Api* fs_api;
|
||||
|
||||
@@ -35,5 +36,9 @@ public:
|
||||
FS_Api& get_fs_api() {
|
||||
return *fs_api;
|
||||
}
|
||||
|
||||
void set_max_line_length(size_t value) {
|
||||
max_line_length = value;
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user