diff --git a/src/mesh/http/ContentHandler.cpp b/src/mesh/http/ContentHandler.cpp index 91f88dda0..50e82f58f 100644 --- a/src/mesh/http/ContentHandler.cpp +++ b/src/mesh/http/ContentHandler.cpp @@ -251,7 +251,7 @@ void htmlDeleteDir(const char *dirname) std::vector> *htmlListDir(std::vector> *fileList, const char *dirname, uint8_t levels) { - File root = FSCom.open(dirname); + File root = FSCom.open(dirname, FILE_O_READ); if (!root) { return NULL; } @@ -264,14 +264,27 @@ std::vector> *htmlListDir(std::vector thisFileMap; thisFileMap[strdup("size")] = strdup(String(file.size()).c_str()); +#ifdef ARCH_ESP32 + thisFileMap[strdup("name")] = strdup(String(file.path()).substring(1).c_str()); +#else thisFileMap[strdup("name")] = strdup(String(file.name()).substring(1).c_str()); +#endif if (String(file.name()).substring(1).endsWith(".gz")) { +#ifdef ARCH_ESP32 + String modifiedFile = String(file.path()).substring(1); +#else String modifiedFile = String(file.name()).substring(1); +#endif modifiedFile.remove((modifiedFile.length() - 3), 3); thisFileMap[strdup("nameModified")] = strdup(modifiedFile.c_str()); } @@ -291,7 +304,7 @@ void handleFsBrowseStatic(HTTPRequest *req, HTTPResponse *res) res->setHeader("Access-Control-Allow-Methods", "GET"); using namespace json11; - auto fileList = htmlListDir(new std::vector>(), "/", 10); + auto fileList = htmlListDir(new std::vector>(), "/static", 10); // create json output structure Json filesystemObj = Json::object{