Merge develop into main (#305)
## New features - Implement translations for apps - Created `tt::settings::setLanguage` and `::getLanguage()` - External app errors are now reported to the user via an AlertDialog - Store system settings in `/data/settings.properties` - Created a "Region & Language" app and moved the timezone setting there. ## Other changes - Change `/data` and `/system` filesystem sector size from 4096 to 512 bytes to allow for more small files (60+ files of 4kB were over the limit of 256kB for the filesystem) - Increased size of `/data` and `/system` - Moved `tt::time::*` to `tt::settings` - Removed the timezone setting from the "Time & Date" setting app - Reverse encoder direction of Lilygo T-Lora Pager - Improved partability of `Time.cpp` (removed separate set of functions for PC/sim)
This commit is contained in:
committed by
GitHub
parent
ee5a5a7181
commit
8c8ccd8783
@@ -222,4 +222,28 @@ bool isDirectory(const std::string& path) {
|
||||
return stat(path.c_str(), &stat_result) == 0 && S_ISDIR(stat_result.st_mode);
|
||||
}
|
||||
|
||||
bool readLines(const std::string& filepath, bool stripNewLine, std::function<void(const char* line)> callback) {
|
||||
auto* file = fopen(filepath.c_str(), "r");
|
||||
if (file == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
char line[1024];
|
||||
|
||||
while (fgets(line, sizeof(line), file) != nullptr) {
|
||||
// Strip newline
|
||||
if (stripNewLine) {
|
||||
size_t line_length = strlen(line);
|
||||
if (line_length > 0 && line[line_length - 1] == '\n') {
|
||||
line[line_length - 1] = '\0';
|
||||
}
|
||||
}
|
||||
// Publish
|
||||
callback(line);
|
||||
}
|
||||
|
||||
fclose(file);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user