MCPcopy Create free account
hub / github.com/crosspoint-reader/crosspoint-reader / loadFromFile

Method loadFromFile

src/CrossPointState.cpp:39–63  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

37}
38
39bool CrossPointState::loadFromFile() {
40 // Try JSON first
41 if (Storage.exists(STATE_FILE_JSON)) {
42 String json = Storage.readFile(STATE_FILE_JSON);
43 if (!json.isEmpty()) {
44 return JsonSettingsIO::loadState(*this, json.c_str());
45 }
46 }
47
48 // Fall back to binary migration
49 if (Storage.exists(STATE_FILE_BIN)) {
50 if (loadFromBinaryFile()) {
51 if (saveToFile()) {
52 Storage.rename(STATE_FILE_BIN, STATE_FILE_BAK);
53 LOG_DBG("CPS", "Migrated state.bin to state.json");
54 return true;
55 } else {
56 LOG_ERR("CPS", "Failed to save state during migration");
57 return false;
58 }
59 }
60 }
61
62 return false;
63}
64
65bool CrossPointState::loadFromBinaryFile() {
66 HalFile inputFile;

Callers 4

setupFunction · 0.45
onEnterMethod · 0.45
onEnterMethod · 0.45
handleSelectionMethod · 0.45

Calls 4

existsMethod · 0.80
readFileMethod · 0.80
renameMethod · 0.80
isEmptyMethod · 0.45

Tested by

no test coverage detected