Fix bug where preferences.json was never closed
This commit is contained in:
parent
2532230c39
commit
64b1b86047
|
@ -92,14 +92,16 @@ namespace msc {
|
||||||
}
|
}
|
||||||
|
|
||||||
void print() {
|
void print() {
|
||||||
File file;
|
Serial.println("Available files:");
|
||||||
FatFile rdir;
|
|
||||||
rdir.open("/");
|
|
||||||
|
|
||||||
// Open next file in root.
|
// Close file(s)
|
||||||
// Warning, openNext starts at the current directory position
|
if (file.isOpen()) file.close();
|
||||||
// so a rewind of the directory may be required.
|
while (!file_stack.empty()) file_stack.pop();
|
||||||
while(file.openNext(&rdir, O_RDONLY)) {
|
|
||||||
|
SdFile root;
|
||||||
|
root.open("/");
|
||||||
|
|
||||||
|
while ( file.openNext(&root, O_RDONLY) ) {
|
||||||
file.printFileSize(&Serial);
|
file.printFileSize(&Serial);
|
||||||
Serial.write(' ');
|
Serial.write(' ');
|
||||||
file.printName(&Serial);
|
file.printName(&Serial);
|
||||||
|
|
|
@ -101,6 +101,7 @@ namespace preferences {
|
||||||
// Open the file and read it into a buffer
|
// Open the file and read it into a buffer
|
||||||
if (!msc::open(PREFERENCES_PATH), false) return;
|
if (!msc::open(PREFERENCES_PATH), false) return;
|
||||||
msc::read(buffer, JSON_SIZE);
|
msc::read(buffer, JSON_SIZE);
|
||||||
|
msc::close();
|
||||||
|
|
||||||
// Deserialize the JSON document
|
// Deserialize the JSON document
|
||||||
DeserializationError error = deserializeJson(config_doc, buffer);
|
DeserializationError error = deserializeJson(config_doc, buffer);
|
||||||
|
|
Loading…
Reference in New Issue