Add sanity check in rmdir

Fix typo in mkdir web command
This commit is contained in:
Luc 2020-09-21 20:30:41 +02:00
parent 7cf4b881fd
commit deda296a10
3 changed files with 10 additions and 3 deletions

View File

@ -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

View File

@ -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<String > 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());

View File

@ -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 ("//", "/");