diff --git a/esp3d/src/modules/filesystem/esp_sd.h b/esp3d/src/modules/filesystem/esp_sd.h index c23d9127..8134c062 100644 --- a/esp3d/src/modules/filesystem/esp_sd.h +++ b/esp3d/src/modules/filesystem/esp_sd.h @@ -41,6 +41,7 @@ public: operator bool() const; bool isDirectory(); const char* name() const; + const char* shortname() const; const char* filename() const; void close(); bool isOpen(); diff --git a/esp3d/src/modules/filesystem/sd/sd_native_esp32.cpp b/esp3d/src/modules/filesystem/sd/sd_native_esp32.cpp index 7d13f9f0..a4bdc17b 100644 --- a/esp3d/src/modules/filesystem/sd/sd_native_esp32.cpp +++ b/esp3d/src/modules/filesystem/sd/sd_native_esp32.cpp @@ -336,6 +336,12 @@ ESP_SDFile ESP_SDFile::openNextFile() return ESP_SDFile(); } +//TODO need to find reliable way +const char* ESP_SDFile::shortname() const +{ + return _name.c_str(); +} + const char * ESP_SD::FilesystemName() { return "SD native"; diff --git a/esp3d/src/modules/filesystem/sd/sd_native_esp8266.cpp b/esp3d/src/modules/filesystem/sd/sd_native_esp8266.cpp index ede4f9db..30aefa53 100644 --- a/esp3d/src/modules/filesystem/sd/sd_native_esp8266.cpp +++ b/esp3d/src/modules/filesystem/sd/sd_native_esp8266.cpp @@ -244,9 +244,9 @@ ESP_SDFile::ESP_SDFile(void* handle, bool isdir, bool iswritemode, const char * //filename char tmp[255]; tSDFile_handle[i].getName(tmp,254); - _filename = tmp; + _filename = path; //name - _name = _filename; + _name = tmp; if (_name.endsWith("/")) { _name.remove( _name.length() - 1,1); _isfakedir = true; @@ -272,6 +272,13 @@ ESP_SDFile::ESP_SDFile(void* handle, bool isdir, bool iswritemode, const char * } } +const char* ESP_SDFile::shortname() const +{ + //static char shorname[13]; + //entry.getSFN(tmps); + return _filename.c_str(); +} + void ESP_SDFile::close() { if (_index != -1) { @@ -303,12 +310,13 @@ ESP_SDFile ESP_SDFile::openNextFile() } sdfat::File tmp = tSDFile_handle[_index].openNextFile(); if (tmp){ - #if defined(ESP_DEBUG_FEATURE) char tmps[255]; tmp.getName(tmps,254); log_esp3d("tmp name :%s %s", tmps, (tmp.isDir())?"isDir":"isFile"); -#endif //ESP_DEBUG_FEATURE - ESP_SDFile esptmp(&tmp, tmp.isDir()); + String s = _filename ; + if (s!="/")s+="/"; + s += tmps; + ESP_SDFile esptmp(&tmp, tmp.isDir(),false, s.c_str()); esptmp.close(); return esptmp; } diff --git a/esp3d/src/modules/filesystem/sd/sdio_esp32.cpp b/esp3d/src/modules/filesystem/sd/sdio_esp32.cpp index 88831602..03f65948 100644 --- a/esp3d/src/modules/filesystem/sd/sdio_esp32.cpp +++ b/esp3d/src/modules/filesystem/sd/sdio_esp32.cpp @@ -330,5 +330,11 @@ const char * ESP_SD::FilesystemName() return "SDIO"; } +//TODO need to find reliable way +const char* ESP_SDFile::shortname() const +{ + return _name.c_str(); +} + #endif //SD_DEVICE == ESP_SDIO #endif //ARCH_ESP32 && SD_DEVICE