29
29
void dir (String path) {
30
30
std::vector<String> directories;
31
31
collectDirectories (path, directories);
32
- for (auto directory: directories) {
32
+ for (auto directory : directories) {
33
33
printDirectoryName (directory.c_str (), 1 );
34
34
File fs = SD.open (directory);
35
35
printFilesInDirectory (fs);
@@ -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
@@ -110,7 +110,7 @@ void printFileName(File file) {
110
110
Serial.print (file.size (), DEC);
111
111
time_t cr = file.getCreationTime ();
112
112
time_t lw = file.getLastWrite ();
113
- struct tm * tmstruct = localtime (&cr);
113
+ struct tm * tmstruct = localtime (&cr);
114
114
Serial.printf (" \t CREATION: %d-%02d-%02d %02d:%02d:%02d" , (tmstruct->tm_year ) + 1900 , (tmstruct->tm_mon ) + 1 , tmstruct->tm_mday , tmstruct->tm_hour , tmstruct->tm_min , tmstruct->tm_sec );
115
115
tmstruct = localtime (&lw);
116
116
Serial.printf (" \t LAST WRITE: %d-%02d-%02d %02d:%02d:%02d\n " , (tmstruct->tm_year ) + 1900 , (tmstruct->tm_mon ) + 1 , tmstruct->tm_mday , tmstruct->tm_hour , tmstruct->tm_min , tmstruct->tm_sec );
@@ -127,8 +127,7 @@ void printFilesInDirectory(File dir) {
127
127
}
128
128
if (file.isDirectory ()) {
129
129
continue ;
130
- }
131
- else {
130
+ } else {
132
131
printFileName (file);
133
132
}
134
133
}
0 commit comments