@@ -64,7 +64,7 @@ void listDirectory() {
64
64
}
65
65
66
66
67
- void printDirectoryName (const char * name, uint8_t level) {
67
+ void printDirectoryName (const char * name, uint8_t level) {
68
68
for (uint8_t i = 0 ; i < level; ++i) {
69
69
Serial.print (" " );
70
70
}
@@ -75,30 +75,30 @@ void printDirectoryName(const char* name, uint8_t level) {
75
75
76
76
// helper function: combine path
77
77
String joinPath (const String &base, const String &name) {
78
- if (base.endsWith (" /" )) {
79
- return base + name;
80
- }
81
- return base + " /" + name;
78
+ if (base.endsWith (" /" )) {
79
+ return base + name;
80
+ }
81
+ return base + " /" + name;
82
82
}
83
83
84
84
// recusive function to collect directory names
85
85
void collectDirectories (const String &dirname, std::vector<String> &directories) {
86
- File root = SD.open (dirname);
87
- if (!root || !root.isDirectory ()) {
88
- Serial.printf (" Error: Verzeichnis %s konnte nicht geöffnet werden\n " , dirname.c_str ());
89
- return ;
90
- }
91
- directories.push_back (dirname); // Verzeichnis speichern
92
-
93
- File file = root.openNextFile ();
94
- while (file) {
95
- if (file.isDirectory ()) {
96
- String fullPath = joinPath (dirname, file.name ()); // Vollständigen Pfad erstellen
97
- collectDirectories (fullPath, directories); // Rekursiver Aufruf
98
- }
99
- file = root.openNextFile ();
100
- }
101
- root.close ();
86
+ File root = SD.open (dirname);
87
+ if (!root || !root.isDirectory ()) {
88
+ Serial.printf (" Error: Verzeichnis %s konnte nicht geöffnet werden\n " , dirname.c_str ());
89
+ return ;
90
+ }
91
+ directories.push_back (dirname); // Verzeichnis speichern
92
+
93
+ File file = root.openNextFile ();
94
+ while (file) {
95
+ if (file.isDirectory ()) {
96
+ String fullPath = joinPath (dirname, file.name ()); // Vollständigen Pfad erstellen
97
+ collectDirectories (fullPath, directories); // Rekursiver Aufruf
98
+ }
99
+ file = root.openNextFile ();
100
+ }
101
+ root.close ();
102
102
}
103
103
104
104
// print filenames
0 commit comments