added listDir

pico-v0.37-esp32-working
alanbjohnston 3 years ago committed by GitHub
parent ccfd432eca
commit f6b1a61268
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -13,8 +13,50 @@ static esp_err_t init_camera();
#define FORMAT_SPIFFS_IF_FAILED true
camera_fb_t *pic;
//File inFile;
//File outFile;
// example code from https://github.com/espressif/arduino-esp32/blob/master/libraries/LittleFS/examples/LITTLEFS_test/LITTLEFS_test.ino
//
void listDir(fs::FS &fs, const char * dirname, uint8_t levels) {
Serial.printf("Listing directory: %s\r\n", dirname);
File root = fs.open(dirname);
if (!root) {
Serial.println("- failed to open directory");
return;
}
if (!root.isDirectory()) {
Serial.println(" - not a directory");
return;
}
File file = root.openNextFile();
while (file) {
if (file.isDirectory()) {
Serial.print(" DIR : ");
Serial.println(file.name());
if (levels) {
listDir(fs, file.name(), levels - 1);
}
} else {
Serial.print(" FILE: ");
Serial.print(file.name());
Serial.print("\tSIZE: ");
Serial.println(file.size());
}
file = root.openNextFile();
}
}
void deleteFile(fs::FS &fs, const char * path) {
Serial.printf("Deleting file: %s\r\n", path);
if (fs.remove(path)) {
Serial.println("- file deleted");
} else {
Serial.println("- delete failed");
}
}
void setup() {
// put your setup code here, to run once:
@ -35,8 +77,8 @@ void setup() {
Serial.println("SPIFFS Mount Failed");
return;
}
}
listDir(SPIFFS, "/", 0);
}
void loop() {
@ -69,6 +111,8 @@ void loop() {
char filename[] = "/cam.bin";
save_camera_image(filename);
listDir(SPIFFS, "/", 0);
picosstvpp();

Loading…
Cancel
Save

Powered by TurnKey Linux.