mirror of
https://git.mirrors.martin98.com/https://github.com/luc-github/ESP3D.git
synced 2025-08-14 04:45:55 +08:00
fix spiffs show . in directory when it should be ignored
This commit is contained in:
parent
c15880ef16
commit
1dfe95f0a0
@ -22,7 +22,7 @@
|
||||
#define _VERSION_ESP3D_H
|
||||
|
||||
//version and sources location
|
||||
#define FW_VERSION "3.0.0.a39"
|
||||
#define FW_VERSION "3.0.0.a40"
|
||||
#define REPOSITORY "https://github.com/luc-github/ESP3D/tree/3.0"
|
||||
|
||||
#endif //_VERSION_ESP3D_H
|
||||
|
@ -272,7 +272,7 @@ ESP_File ESP_File::openNextFile()
|
||||
}
|
||||
File tmp = tFile_handle[_index].openNextFile();
|
||||
while (tmp) {
|
||||
//log_esp3d("tmp name :%s %s", tmp.name(), (tmp.isDirectory())?"isDir":"isFile");
|
||||
log_esp3d("tmp name :%s %s", tmp.name(), (tmp.isDirectory())?"isDir":"isFile");
|
||||
ESP_File esptmp(&tmp, tmp.isDirectory());
|
||||
esptmp.close();
|
||||
String sub = esptmp.filename();
|
||||
@ -281,25 +281,31 @@ ESP_File ESP_File::openNextFile()
|
||||
if (pos!=-1) {
|
||||
//is subdir
|
||||
sub = sub.substring(0,pos);
|
||||
//log_esp3d("file name:%s name: %s %s sub:%s root:%s", esptmp.filename(), esptmp.name(), (esptmp.isDirectory())?"isDir":"isFile", sub.c_str(), _filename.c_str());
|
||||
log_esp3d("file name:%s name: %s %s sub:%s root:%s", esptmp.filename(), esptmp.name(), (esptmp.isDirectory())?"isDir":"isFile", sub.c_str(), _filename.c_str());
|
||||
String tag = "*" + sub + "*";
|
||||
//test if already in directory list
|
||||
if (_dirlist.indexOf(tag) == -1) {//not in list so add it and return the info
|
||||
_dirlist+= tag;
|
||||
String fname = _filename.substring(0,_filename.length()-1) + sub + "/.";
|
||||
//log_esp3d("Found dir name: %s filename:%s", sub.c_str(), fname.c_str());
|
||||
esptmp = ESP_File(sub.c_str(), fname.c_str());
|
||||
return esptmp;
|
||||
log_esp3d("Found dir # name: %s filename:%s", sub.c_str(), fname.c_str());
|
||||
if (sub == ".") {
|
||||
log_esp3d("Dir tag, ignore it");
|
||||
tmp = tFile_handle[_index].openNextFile();
|
||||
} else {
|
||||
esptmp = ESP_File(sub.c_str(), fname.c_str());
|
||||
return esptmp;
|
||||
}
|
||||
} else { //already in list so ignore it
|
||||
//log_esp3d("Dir name: %s already in list", sub.c_str());
|
||||
log_esp3d("Dir name: %s already in list", sub.c_str());
|
||||
tmp = tFile_handle[_index].openNextFile();
|
||||
}
|
||||
} else { //is file
|
||||
//log_esp3d("file name:%s name: %s %s sub:%s root:%s", esptmp.filename(), esptmp.name(), (esptmp.isDirectory())?"isDir":"isFile", sub.c_str(), _filename.c_str());
|
||||
log_esp3d("file name:%s name: %s %s sub:%s root:%s", esptmp.filename(), esptmp.name(), (esptmp.isDirectory())?"isDir":"isFile", sub.c_str(), _filename.c_str());
|
||||
if (sub == ".") {
|
||||
//log_esp3d("Dir tag, ignore it");
|
||||
log_esp3d("Dir tag, ignore it");
|
||||
tmp = tFile_handle[_index].openNextFile();
|
||||
} else {
|
||||
log_esp3d("Found file # name: %s filename:%s", esptmp.filename(), esptmp.name());
|
||||
return esptmp;
|
||||
}
|
||||
}
|
||||
|
@ -310,7 +310,7 @@ ESP_File ESP_File::openNextFile()
|
||||
return ESP_File();
|
||||
}
|
||||
if(tDir_handle[_index].next()) {
|
||||
//log_esp3d("Getting next file from %s", _filename.c_str());
|
||||
log_esp3d("Getting next file from %s", _filename.c_str());
|
||||
File tmp = tDir_handle[_index].openFile("r");
|
||||
while (tmp) {
|
||||
ESP_File esptmp(&tmp);
|
||||
@ -321,17 +321,26 @@ ESP_File ESP_File::openNextFile()
|
||||
if (pos!=-1) {
|
||||
//is subdir
|
||||
sub = sub.substring(0,pos);
|
||||
//log_esp3d("file name:%s name: %s %s sub:%s root:%s", esptmp.filename(), esptmp.name(), (esptmp.isDirectory())?"isDir":"isFile", sub.c_str(), _filename.c_str());
|
||||
log_esp3d("file name:%s name: %s %s sub:%s root:%s", esptmp.filename(), esptmp.name(), (esptmp.isDirectory())?"isDir":"isFile", sub.c_str(), _filename.c_str());
|
||||
String tag = "*" + sub + "*";
|
||||
//test if already in directory list
|
||||
if (_dirlist.indexOf(tag) == -1) {//not in list so add it and return the info
|
||||
_dirlist+= tag;
|
||||
String fname = _filename.substring(0,_filename.length()-1) + sub + "/.";
|
||||
//log_esp3d("Found dir name: %s filename:%s", sub.c_str(), fname.c_str());
|
||||
esptmp = ESP_File(sub.c_str(), fname.c_str());
|
||||
return esptmp;
|
||||
log_esp3d("Found dir # name: %s filename:%s", sub.c_str(), fname.c_str());
|
||||
if (sub == ".") {
|
||||
log_esp3d("Dir tag, ignore it");
|
||||
if(!tDir_handle[_index].next()) {
|
||||
return ESP_File();
|
||||
} else {
|
||||
tmp = tDir_handle[_index].openFile("r");
|
||||
}
|
||||
} else {
|
||||
esptmp = ESP_File(sub.c_str(), fname.c_str());
|
||||
return esptmp;
|
||||
}
|
||||
} else { //already in list so ignore it
|
||||
//log_esp3d("Dir name: %s already in list", sub.c_str());
|
||||
log_esp3d("Dir name: %s already in list", sub.c_str());
|
||||
if(!tDir_handle[_index].next()) {
|
||||
return ESP_File();
|
||||
} else {
|
||||
@ -339,15 +348,16 @@ ESP_File ESP_File::openNextFile()
|
||||
}
|
||||
}
|
||||
} else { //is file
|
||||
//log_esp3d("file name:%s name: %s %s sub:%s root:%s", esptmp.filename(), esptmp.name(), (esptmp.isDirectory())?"isDir":"isFile", sub.c_str(), _filename.c_str());
|
||||
log_esp3d("file name:%s name: %s %s sub:%s root:%s", esptmp.filename(), esptmp.name(), (esptmp.isDirectory())?"isDir":"isFile", sub.c_str(), _filename.c_str());
|
||||
if (sub == ".") {
|
||||
//log_esp3d("Dir tag, ignore it");
|
||||
log_esp3d("Dir tag, ignore it");
|
||||
if(!tDir_handle[_index].next()) {
|
||||
return ESP_File();
|
||||
} else {
|
||||
tmp = tDir_handle[_index].openFile("r");
|
||||
}
|
||||
} else {
|
||||
log_esp3d("Found file # name: %s filename:%s", esptmp.filename(), esptmp.name());
|
||||
return esptmp;
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,9 @@ void HTTP_Server::handle_web_command ()
|
||||
if (_webserver->hasArg ("cmd")) {
|
||||
cmd = _webserver->arg ("cmd");
|
||||
ESP3DOutput output(_webserver);
|
||||
if(!cmd.endsWith("\n")) cmd+="\n";//need to validate command
|
||||
if(!cmd.endsWith("\n")) {
|
||||
cmd+="\n"; //need to validate command
|
||||
}
|
||||
esp3d_commands.process((uint8_t*)cmd.c_str(), cmd.length(), &output, auth_level);
|
||||
} else {
|
||||
_webserver->send (400, "text/plain", "Invalid command");
|
||||
|
Loading…
x
Reference in New Issue
Block a user