From deda296a10f8dce1b73867e143afcb5505e8fbb7 Mon Sep 17 00:00:00 2001 From: Luc <8822552+luc-github@users.noreply.github.com> Date: Mon, 21 Sep 2020 20:30:41 +0200 Subject: [PATCH] Add sanity check in rmdir Fix typo in mkdir web command --- esp3d/src/include/version.h | 2 +- esp3d/src/modules/filesystem/sd/sdio_esp32.cpp | 9 ++++++++- esp3d/src/modules/http/handles/handle-SD-files.cpp | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/esp3d/src/include/version.h b/esp3d/src/include/version.h index 0b9036a0..f207043c 100644 --- a/esp3d/src/include/version.h +++ b/esp3d/src/include/version.h @@ -22,7 +22,7 @@ #define _VERSION_ESP3D_H //version and sources location -#define FW_VERSION "3.0.0.a53" +#define FW_VERSION "3.0.0.a54" #define REPOSITORY "https://github.com/luc-github/ESP3D/tree/3.0" #endif //_VERSION_ESP3D_H diff --git a/esp3d/src/modules/filesystem/sd/sdio_esp32.cpp b/esp3d/src/modules/filesystem/sd/sdio_esp32.cpp index 54ab8f18..56d48a6e 100644 --- a/esp3d/src/modules/filesystem/sd/sdio_esp32.cpp +++ b/esp3d/src/modules/filesystem/sd/sdio_esp32.cpp @@ -199,7 +199,11 @@ bool ESP_SD::remove(const char *path) bool ESP_SD::mkdir(const char *path) { - return SD_MMC.mkdir(path); + String p = path; + if (p.endsWith("/")) { + p.remove( p.length() - 1,1); + } + return SD_MMC.mkdir(p.c_str()); } bool ESP_SD::rmdir(const char *path) @@ -210,6 +214,9 @@ bool ESP_SD::rmdir(const char *path) bool res = true; GenLinkedList pathlist; String p = path; + if (p.endsWith("/")) { + p.remove( p.length() - 1,1); + } pathlist.push(p); while (pathlist.count() > 0) { File dir = SD_MMC.open(pathlist.getLast().c_str()); diff --git a/esp3d/src/modules/http/handles/handle-SD-files.cpp b/esp3d/src/modules/http/handles/handle-SD-files.cpp index 87560211..95ced7ad 100644 --- a/esp3d/src/modules/http/handles/handle-SD-files.cpp +++ b/esp3d/src/modules/http/handles/handle-SD-files.cpp @@ -116,7 +116,7 @@ void HTTP_Server::handleSDFileList () //create a directory if (_webserver->arg ("action") == "createdir" && _webserver->hasArg ("filename") ) { String filename; - filename = path + _webserver->arg ("filename") + "/."; + filename = path + _webserver->arg ("filename"); String shortname = _webserver->arg ("filename"); shortname.replace ("/", ""); filename.replace ("//", "/");