Selaa lähdekoodia

BlueSCSI Toolbox: create shared dir if doesnt exist

Eric Helgeson 4 kuukautta sitten
vanhempi
sitoutus
d968af1c07
1 muutettua tiedostoa jossa 5 lisäystä ja 1 poistoa
  1. 5 1
      src/BlueSCSI_Toolbox.cpp

+ 5 - 1
src/BlueSCSI_Toolbox.cpp

@@ -112,7 +112,11 @@ static void onListFiles(const char * dir_name, bool isCD = false) {
     uint8_t index = 0;
     uint8_t file_entry[ENTRY_SIZE] = {0};
 
-    dir.open(dir_name);
+    if (!dir.open(dir_name)) {
+        if (!SD.mkdir(dir_name) || !dir.open(dir_name)) {
+            logmsg("ERROR: Could not open or create BlueSCSI Toolbox shared dir: ", dir_name);
+        }
+    }
     dir.rewindDirectory();
     while (file.openNext(&dir, O_RDONLY))
     {