20 #include "../../../include/esp3d_config.h"
21 #if (FILESYSTEM_FEATURE == ESP_LITTLEFS_FILESYSTEM)
22 #include "../esp_filesystem.h"
23 #include "../../../core/genLinkedList.h"
32 _started = LittleFS.begin();
50 return info.totalBytes;
57 return info.usedBytes;
62 return LittleFS.rename(oldpath,newpath);
72 return LittleFS.format();
93 if (ftmp.isDirectory()) {
99 Dir dtmp = LittleFS.openDir(path);
100 ESP_File esptmp(&dtmp,
true,
false, path);
108 if (strcmp(path,
"/") == 0) {
113 if (spath[spath.length()-1] ==
'/') {
115 spath.remove(spath.length()-1);
118 return LittleFS.exists(spath.c_str());
123 return LittleFS.remove(path);
130 if (spath[spath.length()-1] ==
'/') {
132 spath.remove(spath.length()-1);
135 return LittleFS.mkdir(spath.c_str());
147 if (spath[spath.length()-1] !=
'/') {
150 if (spath[0] !=
'/') {
153 pathlist.
push(spath);
154 while (pathlist.
count() > 0) {
156 bool candelete =
true;
157 if (LittleFS.exists(spath.c_str())) {
158 Dir
dir = LittleFS.openDir(pathlist.
getLast().c_str());
162 String newdir = pathlist.
getLast() +
dir.fileName() +
"/";
163 pathlist.
push(newdir);
166 String s = spath +
dir.fileName();
173 if (spath[spath.length()-1] ==
'/') {
174 spath.remove(spath.length()-1);
176 if (LittleFS.exists(spath.c_str())) {
177 res = LittleFS.rmdir(spath.c_str());
179 log_esp3d(
"rmdir %s %d", spath.c_str(), res);
190 tDir_handle[i] = Dir();
205 _iswritemode = iswritemode;
213 if (tDir_handle[i].fileName().length() == 0) {
214 tDir_handle[i] = *((Dir *)handle);
220 if (!((_filename[_filename.length()-1] ==
'/') || (_filename ==
"/"))) {
225 if (_filename ==
"/") {
228 _name.remove( 0, _name.lastIndexOf(
'/')+1);
244 if (!((_filename[_filename.length()-1] ==
'/') || (_filename ==
"/"))) {
249 if (_filename ==
"/") {
253 if (_name[0] ==
'/') {
256 int pos = _name.lastIndexOf(
'/');
258 _name.remove( 0, pos+1);
279 tDir_handle[_index] = Dir();
287 if (_iswritemode && !_isdir) {
288 File ftmp = LittleFS.open(_filename.c_str(),
"r");
304 if ((_index == -1) || !_isdir) {
308 if(tDir_handle[_index].next()) {
309 String
name = tDir_handle[_index].fileName();
310 log_esp3d(
"Getting next file from %s", _filename.c_str());
311 log_esp3d(
"name :%s %s",
name.c_str(), (tDir_handle[_index].isDirectory())?
"isDir":
"isFile");
312 String s = _filename;
313 if(s[s.length()-1]!=
'/') {
317 if (tDir_handle[_index].isFile()) {
318 ESP_File esptmp(
name.c_str(), s.c_str(),
false, tDir_handle[_index].fileSize()) ;
321 log_esp3d(
"Found dir name: %s filename:%s",
name.c_str(), s.c_str());
330 #endif //ESP_LITTLEFS_FILESYSTEM