mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2026-02-06 23:57:39 +03:00
Update serialization
This commit is contained in:
parent
efdcdb88fa
commit
bb21667771
@ -47,6 +47,17 @@ static void readString(FsFile& file, std::string& s) {
|
||||
uint32_t len;
|
||||
readPod(file, len);
|
||||
s.resize(len);
|
||||
file.read(&s[0], len);
|
||||
file.read(s.data(), len);
|
||||
}
|
||||
|
||||
static void readString(FsFile& file, char* s, size_t buf_size) {
|
||||
uint32_t len;
|
||||
readPod(file, len);
|
||||
auto lenToRead = std::min(buf_size - 1, len);
|
||||
file.read(s, lenToRead);
|
||||
s[lenToRead] = '\0';
|
||||
if (lenToRead < len) {
|
||||
file.seek(len - lenToRead);
|
||||
}
|
||||
}
|
||||
} // namespace serialization
|
||||
|
||||
@ -106,12 +106,7 @@ bool CrossPointSettings::loadFromFile() {
|
||||
if (++settingsRead >= fileSettingsCount) break;
|
||||
serialization::readPod(inputFile, sleepScreenCoverMode);
|
||||
if (++settingsRead >= fileSettingsCount) break;
|
||||
{
|
||||
std::string urlStr;
|
||||
serialization::readString(inputFile, urlStr);
|
||||
strncpy(opdsServerUrl, urlStr.c_str(), sizeof(opdsServerUrl) - 1);
|
||||
opdsServerUrl[sizeof(opdsServerUrl) - 1] = '\0';
|
||||
}
|
||||
serialization::readString(inputFile, opdsServerUrl, sizeof(opdsServerUrl));
|
||||
if (++settingsRead >= fileSettingsCount) break;
|
||||
serialization::readPod(inputFile, textAntiAliasing);
|
||||
if (++settingsRead >= fileSettingsCount) break;
|
||||
@ -121,12 +116,7 @@ bool CrossPointSettings::loadFromFile() {
|
||||
if (++settingsRead >= fileSettingsCount) break;
|
||||
serialization::readPod(inputFile, hyphenationEnabled);
|
||||
if (++settingsRead >= fileSettingsCount) break;
|
||||
{
|
||||
std::string urlPath;
|
||||
serialization::readString(inputFile, urlPath);
|
||||
strncpy(opdsPath, urlPath.c_str(), sizeof(opdsPath) - 1);
|
||||
opdsPath[sizeof(opdsPath) - 1] = '\0';
|
||||
}
|
||||
serialization::readString(inputFile, opdsPath, sizeof(opdsPath));
|
||||
if (++settingsRead >= fileSettingsCount) break;
|
||||
} while (false);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user