MCPcopy Create free account
hub / github.com/bmorcelli/Launcher / listFiles

Function listFiles

src/webInterface.cpp:85–113  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

83}
84
85String 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
115void ensurePersistedSessionLoaded() {
116 if (sessionTokenLoaded) return;

Callers 1

listFilesHandlerFunction · 0.85

Calls 3

launcherConsolePrintlnFunction · 0.85
closeMethod · 0.80
humanReadableSizeFunction · 0.70

Tested by

no test coverage detected