Skip to content

Commit

Permalink
Adapt further clang findings
Browse files Browse the repository at this point in the history
  • Loading branch information
hasenradball committed Nov 18, 2024
1 parent 4e430d6 commit 300af91
Showing 1 changed file with 23 additions and 24 deletions.
47 changes: 23 additions & 24 deletions libraries/SD/examples/listFilesEnhanced/listfilesEnhanced.ino
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
void dir(String path) {
std::vector<String> directories;
collectDirectories(path, directories);
for (auto directory:directories) {
for (auto directory : directories) {
printDirectoryName(directory.c_str(), 1);
File fs = SD.open(directory);
printFilesInDirectory(fs);
Expand Down Expand Up @@ -75,30 +75,30 @@ void printDirectoryName(const char* name, uint8_t level) {

Check failure on line 75 in libraries/SD/examples/listFilesEnhanced/listfilesEnhanced.ino

View workflow job for this annotation

GitHub Actions / clang-format

Run tests/restyle.sh and re-commit libraries/SD/examples/listFilesEnhanced/listfilesEnhanced.ino

File libraries/SD/examples/listFilesEnhanced/listfilesEnhanced.ino failed clang-format style check. (lines 64, 75)
// helper function: combine path
String joinPath(const String &base, const String &name) {
if (base.endsWith("/")) {
return base + name;
}
return base + "/" + name;
if (base.endsWith("/")) {
return base + name;
}
return base + "/" + name;
}

// recusive function to collect directory names
void collectDirectories(const String &dirname, std::vector<String> &directories) {
File root = SD.open(dirname);
if (!root || !root.isDirectory()) {
Serial.printf("Error: Verzeichnis %s konnte nicht geöffnet werden\n", dirname.c_str());
return;
}
directories.push_back(dirname); // Verzeichnis speichern

File file = root.openNextFile();
while (file) {
if (file.isDirectory()) {
String fullPath = joinPath(dirname, file.name()); // Vollständigen Pfad erstellen
collectDirectories(fullPath, directories); // Rekursiver Aufruf
}
file = root.openNextFile();
}
root.close();
File root = SD.open(dirname);
if (!root || !root.isDirectory()) {
Serial.printf("Error: Verzeichnis %s konnte nicht geöffnet werden\n", dirname.c_str());
return;
}
directories.push_back(dirname); // Verzeichnis speichern

File file = root.openNextFile();
while (file) {
if (file.isDirectory()) {
String fullPath = joinPath(dirname, file.name()); // Vollständigen Pfad erstellen
collectDirectories(fullPath, directories); // Rekursiver Aufruf
}
file = root.openNextFile();
}
root.close();
}

// print filenames
Expand All @@ -110,7 +110,7 @@ void printFileName(File file) {
Serial.print(file.size(), DEC);
time_t cr = file.getCreationTime();
time_t lw = file.getLastWrite();
struct tm* tmstruct = localtime(&cr);
struct tm *tmstruct = localtime(&cr);
Serial.printf("\tCREATION: %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);
tmstruct = localtime(&lw);
Serial.printf("\tLAST 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);
Expand All @@ -127,8 +127,7 @@ void printFilesInDirectory(File dir) {
}
if (file.isDirectory()) {
continue;
}
else {
} else {
printFileName(file);
}
}
Expand Down

0 comments on commit 300af91

Please sign in to comment.