mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2025-12-19 15:47:40 +03:00
* Move to smart pointers and split out ParsedText class * Cleanup ParsedText * Fix clearCache functions and clear section cache if page load fails * Bump Page and Section file versions * Combine removeDir implementations in Epub * Adjust screen margins
37 lines
658 B
C++
37 lines
658 B
C++
#include "FsHelpers.h"
|
|
|
|
#include <SD.h>
|
|
|
|
bool FsHelpers::removeDir(const char* path) {
|
|
// 1. Open the directory
|
|
File dir = SD.open(path);
|
|
if (!dir) {
|
|
return false;
|
|
}
|
|
if (!dir.isDirectory()) {
|
|
return false;
|
|
}
|
|
|
|
File file = dir.openNextFile();
|
|
while (file) {
|
|
String filePath = path;
|
|
if (!filePath.endsWith("/")) {
|
|
filePath += "/";
|
|
}
|
|
filePath += file.name();
|
|
|
|
if (file.isDirectory()) {
|
|
if (!removeDir(filePath.c_str())) {
|
|
return false;
|
|
}
|
|
} else {
|
|
if (!SD.remove(filePath.c_str())) {
|
|
return false;
|
|
}
|
|
}
|
|
file = dir.openNextFile();
|
|
}
|
|
|
|
return SD.rmdir(path);
|
|
}
|