20 #include "../../../include/esp3d_config.h"
21 #if defined (ARDUINO_ARCH_ESP32) && defined(SD_DEVICE)
22 #if (SD_DEVICE == ESP_SDIO)
23 #include "../esp_sd.h"
24 #include "../../../core/genLinkedList.h"
25 #include "../../../core/settings_esp3d.h"
32 #define SDMMC_FORCE_BEGIN
36 static bool lastinitok =
false;
37 #ifdef SDMMC_FORCE_BEGIN
39 #endif //SDMMC_LIGHT_CHECK
40 #if defined(ESP_SD_DETECT_PIN) && ESP_SD_DETECT_PIN != -1
46 #endif //ESP_SD_DETECT_PIN
58 log_esp3d(
"last init was failed try sd_mmc begin");
62 if (SD_MMC.cardType() != CARD_NONE ) {
73 log_esp3d(
"last init was ok try card type");
74 if(SD_MMC.cardType() != CARD_NONE) {
75 log_esp3d(
"checking sd_mmc card type succeed");
83 if ( SD_MMC.cardType() != CARD_NONE ) {
86 log_esp3d(
"new sd_mmc card type succeed");
102 #ifdef SDMMC_FORCE_BEGIN
106 #endif //SDMMC_FORCE_BEGIN
120 return SD_MMC.totalBytes();
125 return SD_MMC.usedBytes();
130 return (SD_MMC.totalBytes() - SD_MMC.usedBytes());
135 return SD_MMC.rename(oldpath,newpath);
154 if (path[0] !=
'/') {
160 p.remove(p.lastIndexOf(
'/') +1);
175 if (strcmp(path,
"/") == 0) {
178 res = SD_MMC.exists(path);
190 return SD_MMC.remove(path);
195 return SD_MMC.mkdir(path);
207 while (pathlist.
count() > 0) {
208 File
dir = SD_MMC.open(pathlist.
getLast().c_str());
210 bool candelete =
true;
212 if (f.isDirectory()) {
214 String newdir = f.
name();
215 pathlist.
push(newdir);
219 SD_MMC.remove(f.name());
225 if (pathlist.
getLast() !=
"/") {
226 res = SD_MMC.rmdir(pathlist.
getLast().c_str());
253 _iswritemode = iswritemode;
265 if (_name.endsWith(
"/")) {
266 _name.remove( _name.length() - 1,1);
269 if (_name[0] ==
'/') {
272 int pos = _name.lastIndexOf(
'/');
274 _name.remove( 0, pos+1);
276 if (_name.length() == 0) {
297 if (_iswritemode && !_isdir) {
298 File ftmp = SD_MMC.open(_filename.c_str());
301 _lastwrite = ftmp.getLastWrite();
313 if ((_index == -1) || !_isdir) {
319 log_esp3d(
"tmp name :%s %s %s", tmp.name(), (tmp.isDirectory())?
"isDir":
"isFile", _filename.c_str());
320 String s = tmp.name() ;
323 ESP_SDFile esptmp(&tmp, tmp.isDirectory(),
false, s.c_str());
333 return _name.c_str();
340 #endif //SD_DEVICE == ESP_SDIO
341 #endif //ARCH_ESP32 && SD_DEVICE