| 83 | } |
| 84 | |
| 85 | String listFiles(String folder) { |
| 86 | String returnText = "pa:" + folder + ":0\n"; |
| 87 | launcherConsolePrintln("Listing files stored on SD"); |
| 88 | |
| 89 | File root = SDM.open(folder); |
| 90 | uploadFolder = folder; |
| 91 | |
| 92 | while (true) { |
| 93 | bool isDir; |
| 94 | String fullPath = root.getNextFileName(&isDir); |
| 95 | String nameOnly = fullPath.substring(fullPath.lastIndexOf("/") + 1); |
| 96 | if (fullPath == "") break; |
| 97 | |
| 98 | if (esp_get_free_heap_size() > (String("Fo:" + nameOnly + ":0\n").length()) + 1024) { |
| 99 | if (isDir) { |
| 100 | returnText += "Fo:" + nameOnly + ":0\n"; |
| 101 | } else { |
| 102 | File fileForSize = SDM.open(fullPath); |
| 103 | if (fileForSize) { |
| 104 | returnText += "Fi:" + nameOnly + ":" + humanReadableSize(fileForSize.size()) + "\n"; |
| 105 | fileForSize.close(); |
| 106 | } |
| 107 | } |
| 108 | } else break; |
| 109 | esp_task_wdt_reset(); |
| 110 | } |
| 111 | root.close(); |
| 112 | return returnText; |
| 113 | } |
| 114 | |
| 115 | void ensurePersistedSessionLoaded() { |
| 116 | if (sessionTokenLoaded) return; |
no test coverage detected