Skip to content

Commit ee18988

Browse files
committed
Fix rmdir does not remove not empty directory
Remove SDFat V1 support as not necessary now have SDFat 2.x Remove SPIFFS esp8266 support as now removed from core Bump version Remove outdated test scripts
1 parent 159b9e6 commit ee18988

File tree

1,516 files changed

+144
-296870
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,516 files changed

+144
-296870
lines changed

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
"unordered_set": "cpp",
1111
"vector": "cpp",
1212
"string_view": "cpp",
13-
"initializer_list": "cpp"
13+
"initializer_list": "cpp",
14+
"typeinfo": "cpp"
1415
},
1516
"cmake.configureOnOpen": false
1617
}

esp3d/configuration.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,6 @@
245245
/* SD card library
246246
* ESP_SD_NATIVE //esp32 / esp8266
247247
* ESP_SDIO //esp32 only
248-
* ESP_SDFAT //esp8266 / esp32
249248
* ESP_SDFAT2 //esp8266 / esp32
250249
*/
251250
//#define SD_DEVICE ESP_SDFAT2

esp3d/src/include/defines.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,7 @@
200200
//SD READER FS type supported
201201
#define ESP_SD_NATIVE 1
202202
#define ESP_SDIO 2
203-
#define ESP_SDFAT 3
204-
#define ESP_SDFAT2 4
203+
#define ESP_SDFAT2 3
205204

206205
//SDIO Mode
207206
#define SD_ONE_BIT_MODE 1

esp3d/src/include/version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#define _VERSION_ESP3D_H
2323

2424
//version and sources location
25-
#define FW_VERSION "3.0.0.a208"
25+
#define FW_VERSION "3.0.0.a209"
2626
#define REPOSITORY "https://github.com/luc-github/ESP3D/tree/3.0"
2727

2828
#endif //_VERSION_ESP3D_H

esp3d/src/modules/filesystem/flash/fat_esp32_filesystem.cpp

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -143,35 +143,39 @@ bool ESP_FileSystem::mkdir(const char *path)
143143
bool ESP_FileSystem::rmdir(const char *path)
144144
{
145145
String p = path;
146-
if(p[0]!='/') {
147-
p="/"+p;
146+
if (!p.startsWith("/")) {
147+
p = '/'+p;
148148
}
149-
if (p[p.length()-1] == '/') {
150-
if (p!="/") {
149+
if (p!= "/") {
150+
if (p.endsWith("/")) {
151151
p.remove(p.length()-1);
152152
}
153153
}
154-
155154
if (!exists(p.c_str())) {
156155
return false;
157156
}
158157
bool res = true;
159158
std::stack <String > pathlist;
160159
pathlist.push(p);
161-
while (pathlist.size() > 0) {
160+
while (pathlist.size() > 0 && res) {
162161
File dir = FFat.open(pathlist.top().c_str());
163162
File f = dir.openNextFile();
164163
bool candelete = true;
165-
while (f) {
164+
while (f && res) {
166165
if (f.isDirectory()) {
167166
candelete = false;
168-
String newdir = f.name();
167+
String newdir = pathlist.top()+ '/';
168+
newdir+= f.name();
169169
pathlist.push(newdir);
170170
f.close();
171171
f = File();
172172
} else {
173-
FFat.remove(f.name());
173+
String filepath = pathlist.top()+ '/';
174+
filepath+= f.name();
174175
f.close();
176+
if (!FFat.remove(filepath.c_str())) {
177+
res = false;
178+
}
175179
f = dir.openNextFile();
176180
}
177181
}

esp3d/src/modules/filesystem/flash/littlefs_esp32_filesystem.cpp

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -150,35 +150,39 @@ bool ESP_FileSystem::mkdir(const char *path)
150150
bool ESP_FileSystem::rmdir(const char *path)
151151
{
152152
String p = path;
153-
if(p[0]!='/') {
154-
p="/"+p;
153+
if (!p.startsWith("/")) {
154+
p = '/'+p;
155155
}
156-
if (p[p.length()-1] == '/') {
157-
if (p!="/") {
156+
if (p!= "/") {
157+
if (p.endsWith("/")) {
158158
p.remove(p.length()-1);
159159
}
160160
}
161-
162161
if (!exists(p.c_str())) {
163162
return false;
164163
}
165164
bool res = true;
166165
std::stack <String> pathlist;
167166
pathlist.push(p);
168-
while (pathlist.size() > 0) {
167+
while (pathlist.size() > 0 && res) {
169168
File dir = LittleFS.open(pathlist.top().c_str());
170169
File f = dir.openNextFile();
171170
bool candelete = true;
172-
while (f) {
171+
while (f && res) {
173172
if (f.isDirectory()) {
174173
candelete = false;
175-
String newdir = f.name();
174+
String newdir = pathlist.top()+ '/';
175+
newdir+= f.name();
176176
pathlist.push(newdir);
177177
f.close();
178178
f = File();
179179
} else {
180-
LittleFS.remove(f.name());
180+
String filepath = pathlist.top()+ '/';
181+
filepath+= f.name();
181182
f.close();
183+
if (!LittleFS.remove(filepath.c_str())) {
184+
res = false;
185+
}
182186
f = dir.openNextFile();
183187
}
184188
}

esp3d/src/modules/filesystem/flash/littlefs_esp8266_filesystem .cpp

Lines changed: 24 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -153,46 +153,40 @@ bool ESP_FileSystem::mkdir(const char *path)
153153

154154
bool ESP_FileSystem::rmdir(const char *path)
155155
{
156-
if (!exists(path)) {
156+
String p = path;
157+
if (!p.endsWith("/")) {
158+
p+= '/';
159+
}
160+
if (!p.startsWith("/")) {
161+
p = '/'+p;
162+
}
163+
if (!exists(p.c_str())) {
157164
return false;
158165
}
159166
bool res = true;
160167
std::stack <String> pathlist;
161-
String spath = path;
162-
spath.trim();
163-
if (spath[spath.length()-1] != '/') {
164-
spath+="/";
165-
}
166-
if (spath[0] != '/') {
167-
spath ="/" + spath;
168-
}
169-
pathlist.push(spath);
168+
pathlist.push(p);
170169
while (pathlist.size() > 0) {
171-
spath=pathlist.top();
170+
172171
bool candelete = true;
173-
if (LittleFS.exists(spath.c_str())) {
174-
Dir dir = LittleFS.openDir(pathlist.top().c_str());
175-
while (dir.next()) {
176-
if (dir.isDirectory()) {
177-
candelete = false;
178-
String newdir = pathlist.top() + dir.fileName() + "/";
179-
pathlist.push(newdir);
180-
} else {
181-
log_esp3d("remove %s", dir.fileName().c_str());
182-
String s = spath + dir.fileName();
183-
LittleFS.remove(s);
184-
}
172+
Dir dir = LittleFS.openDir(pathlist.top().c_str());
173+
while (dir.next()) {
174+
if (dir.isDirectory()) {
175+
candelete = false;
176+
String newdir = pathlist.top() + dir.fileName() + "/";
177+
pathlist.push(newdir);
178+
} else {
179+
String filepath = pathlist.top()+ '/';
180+
filepath+= dir.fileName();
181+
log_esp3d("remove %s", filepath.c_str());
182+
LittleFS.remove(filepath.c_str());
185183
}
186184
}
187185
if (candelete) {
188-
if (spath !="/") {
189-
if (spath[spath.length()-1] == '/') {
190-
spath.remove(spath.length()-1);
191-
}
192-
if (LittleFS.exists(spath.c_str())) {
193-
res = LittleFS.rmdir(spath.c_str());
186+
if (pathlist.top() !="/") {
187+
if (LittleFS.exists(pathlist.top().c_str())) {
188+
res = LittleFS.rmdir(pathlist.top().c_str());
194189
}
195-
log_esp3d("rmdir %s %d", spath.c_str(), res);
196190
}
197191
pathlist.pop();
198192
}

esp3d/src/modules/filesystem/flash/spiffs_esp32_filesystem.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,11 @@ bool ESP_FileSystem::rmdir(const char *path)
168168
{
169169
String spath = path;
170170
spath.trim();
171-
if(spath[0]!='/') {
172-
spath="/"+spath;
171+
if (!spath.startsWith("/")) {
172+
spath = '/'+spath;
173173
}
174-
if (spath[spath.length()-1] == '/') {
175-
if (spath!="/") {
174+
if (spath!= "/") {
175+
if (spath.endsWith("/")) {
176176
spath.remove(spath.length()-1);
177177
}
178178
}

0 commit comments

Comments
 (0)