20 #include "../../../include/esp3d_config.h"
21 #if (FILESYSTEM_FEATURE == ESP_SPIFFS_FILESYSTEM) && defined (ARDUINO_ARCH_ESP8266)
22 #include "../esp_filesystem.h"
23 #include "../../../core/genLinkedList.h"
30 _started = SPIFFS.begin();
48 return info.totalBytes;
55 return info.usedBytes;
60 return SPIFFS.rename(oldpath,newpath);
70 return SPIFFS.format();
90 Dir dtmp = SPIFFS.openDir(path);
91 ESP_File esptmp(&dtmp,
true,
false, path);
99 if (strcmp(path,
"/") == 0) {
104 if (spath[spath.length()-1] ==
'/') {
106 spath.remove(spath.length()-1);
109 res = SPIFFS.exists(spath.c_str());
111 String newpath = spath;
112 if (newpath[newpath.length()-1] !=
'/') {
117 res = SPIFFS.exists(newpath);
136 return SPIFFS.remove(path);
143 if (p[p.length()-1] !=
'/') {
159 Dir dtmp = SPIFFS.openDir(path);
160 while (dtmp.next()) {
161 if (!SPIFFS.remove(dtmp.fileName().c_str())) {
171 tDir_handle[i] = Dir();
186 _iswritemode = iswritemode;
194 if (tDir_handle[i].fileName().length() == 0) {
195 tDir_handle[i] = *((Dir *)handle);
200 if (_filename ==
"/") {
203 if (_filename[_filename.length()-1] !=
'.') {
204 if (_filename[_filename.length()-2] !=
'/') {
211 if (_filename ==
"/.") {
215 if (_name.length() >=2) {
216 if ((_name[_name.length() - 1] ==
'.') && (_name[_name.length() - 2] ==
'/')) {
217 _name.remove( _name.length() - 2,2);
220 _name.remove( 0, _name.lastIndexOf(
'/')+1);
236 if (_filename ==
"/") {
240 if (_filename[_filename.length()-1] !=
'.') {
241 if (_filename[_filename.length()-2] !=
'/') {
248 if (_filename ==
"/.") {
252 if (_name.endsWith(
"/.")) {
253 _name.remove( _name.length() - 2,2);
257 if (_name[0] ==
'/') {
260 int pos = _name.lastIndexOf(
'/');
262 _name.remove( 0, pos+1);
281 if (_isdir && !_isfakedir) {
283 tDir_handle[_index] = Dir();
291 if (_iswritemode && !_isdir) {
292 File ftmp = SPIFFS.open(_filename.c_str(),
"r");
308 if ((_index == -1) || !_isdir) {
312 if(tDir_handle[_index].next()) {
314 File tmp = tDir_handle[_index].openFile(
"r");
319 sub.remove(0,_filename.length()-1);
320 int pos = sub.indexOf(
"/");
323 sub = sub.substring(0,pos);
325 String tag =
"*" + sub +
"*";
327 if (_dirlist.indexOf(tag) == -1) {
329 String fname = _filename.substring(0,_filename.length()-1) + sub +
"/.";
331 esptmp =
ESP_File(sub.c_str(), fname.c_str());
335 if(!tDir_handle[_index].next()) {
338 tmp = tDir_handle[_index].openFile(
"r");
345 if(!tDir_handle[_index].next()) {
348 tmp = tDir_handle[_index].openFile(
"r");
360 #endif //ESP_SPIFFS_FILESYSTEM