mirror of
https://git.mirrors.martin98.com/https://github.com/luc-github/ESP3D.git
synced 2025-08-05 14:20:41 +08:00
Add sanity checks in ESP32 native functions
This commit is contained in:
parent
deda296a10
commit
7e2d6222ee
@ -22,7 +22,7 @@
|
||||
#define _VERSION_ESP3D_H
|
||||
|
||||
//version and sources location
|
||||
#define FW_VERSION "3.0.0.a54"
|
||||
#define FW_VERSION "3.0.0.a55"
|
||||
#define REPOSITORY "https://github.com/luc-github/ESP3D/tree/3.0"
|
||||
|
||||
#endif //_VERSION_ESP3D_H
|
||||
|
@ -142,13 +142,17 @@ ESP_SDFile ESP_SD::open(const char* path, uint8_t mode)
|
||||
bool ESP_SD::exists(const char* path)
|
||||
{
|
||||
bool res = false;
|
||||
String p = path;
|
||||
//root should always be there if started
|
||||
if (strcmp(path, "/") == 0) {
|
||||
if (p == "/") {
|
||||
return _started;
|
||||
}
|
||||
res = SD.exists(path);
|
||||
if (p.endsWith("/")) {
|
||||
p.remove( p.length() - 1,1);
|
||||
}
|
||||
res = SD.exists(p);
|
||||
if (!res) {
|
||||
ESP_SDFile root = ESP_SD::open(path, ESP_FILE_READ);
|
||||
ESP_SDFile root = ESP_SD::open(p.c_str(), ESP_FILE_READ);
|
||||
if (root) {
|
||||
res = root.isDirectory();
|
||||
}
|
||||
@ -163,7 +167,11 @@ bool ESP_SD::remove(const char *path)
|
||||
|
||||
bool ESP_SD::mkdir(const char *path)
|
||||
{
|
||||
return SD.mkdir(path);
|
||||
String p = path;
|
||||
if (p.endsWith("/")) {
|
||||
p.remove( p.length() - 1,1);
|
||||
}
|
||||
return SD.mkdir(p.c_str());
|
||||
}
|
||||
|
||||
bool ESP_SD::rmdir(const char *path)
|
||||
@ -174,6 +182,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.open(pathlist.getLast().c_str());
|
||||
|
Loading…
x
Reference in New Issue
Block a user