From 2ef9bb92067b570cf761320289e8837acf62c013 Mon Sep 17 00:00:00 2001 From: Ton Huisman Date: Fri, 25 Aug 2023 10:59:59 +0200 Subject: [PATCH 1/2] [SD-card] Bugfix: Opening a file from SD-card doesn't always work --- src/src/Helpers/ESPEasy_Storage.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/src/Helpers/ESPEasy_Storage.cpp b/src/src/Helpers/ESPEasy_Storage.cpp index b7e6cde316..5864d35d71 100644 --- a/src/src/Helpers/ESPEasy_Storage.cpp +++ b/src/src/Helpers/ESPEasy_Storage.cpp @@ -184,8 +184,7 @@ fs::File tryOpenFile(const String& fname, const String& mode, FileDestination_e # if FEATURE_SD if (!f && ((destination == FileDestination_e::ANY) || (destination == FileDestination_e::SD))) { - // FIXME TD-er: Should this fallback to SD only be done on "r" mode? - f = SD.open(fname.c_str(), mode.c_str()); + f = SD.open(patch_fname(fname).c_str(), mode.c_str()); } # endif // if FEATURE_SD From 5ab48538b654a307c9cf991ac15516d0002fafe8 Mon Sep 17 00:00:00 2001 From: Ton Huisman Date: Fri, 25 Aug 2023 11:43:42 +0200 Subject: [PATCH 2/2] [SD-browser] Code improvements --- src/src/WebServer/FileList.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/src/WebServer/FileList.cpp b/src/src/WebServer/FileList.cpp index 13bbb8a059..30b951d68e 100644 --- a/src/src/WebServer/FileList.cpp +++ b/src/src/WebServer/FileList.cpp @@ -413,12 +413,9 @@ void handle_SDfilelist() { // size_t entrynameLength = strlen(entry.name()); if (entry.isDirectory()) { - char SDcardChildDir[80]; - // take a look in the directory for entries String child_dir = current_dir + entry.name(); - child_dir.toCharArray(SDcardChildDir, child_dir.length() + 1); - fs::File child = SD.open(SDcardChildDir); + fs::File child = SD.open(child_dir.c_str()); fs::File dir_has_entry = child.openNextFile(); // when the directory is empty, display the button to delete them