Исправляем ошибку в алгоритме чтения директории. openNextFile() возвращает файл.

This commit is contained in:
2021-12-03 11:18:48 +03:00
parent f668b5783e
commit 2b1ab1df50

View File

@@ -184,21 +184,22 @@ void FSEditor::getDirList(const String &path, String &output) {
} }
#else #else
void FSEditor::getDirList(const String &path, String &output) { void FSEditor::getDirList(const String &path, String &output) {
auto dir = _fs.open(path, FILE_READ); File dir = _fs.open(path.c_str(), FILE_READ);
dir.rewindDirectory(); dir.rewindDirectory();
while (dir.openNextFile()) { File file;
String fname = dir.name(); while (file = dir.openNextFile()) {
if (!path.endsWith("/") && !fname.startsWith("/")) { String fname = file.name();
fname = "/" + fname; //if (!path.endsWith("/") && !fname.startsWith("/")) {
} // fname = "/" + fname;
fname = path + fname; //}
if (isExcluded(_fs, fname.c_str())) { //fname = path + fname;
continue; //if (isExcluded(_fs, fname.c_str())) {
} // continue;
if (dir.isDirectory()) { //}
getDirList(fname, output); //if (dir.isDirectory()) {
continue; // getDirList(fname, output);
} // continue;
//}
if (output != "[") output += ','; if (output != "[") output += ',';
char buf[128]; char buf[128];
sprintf(buf, "{\"type\":\"file\",\"name\":\"%s\",\"size\":%d}", fname.c_str(), dir.size()); sprintf(buf, "{\"type\":\"file\",\"name\":\"%s\",\"size\":%d}", fname.c_str(), dir.size());