mirror of
https://github.com/0015/ThatProject.git
synced 2026-01-12 17:27:43 +03:00
Twitter Hash Search Application with #️⃣NodeMCU(ESP8266) #️⃣ILI9341
This commit is contained in:
88
ESP8266_Twitter_Hash_Search/List_SPIFFS.h
Normal file
88
ESP8266_Twitter_Hash_Search/List_SPIFFS.h
Normal file
@@ -0,0 +1,88 @@
|
||||
//https://github.com/Bodmer/TJpg_Decoder
|
||||
/***************************************************************************************
|
||||
** Function name: listSPIFFS
|
||||
** Description: Listing SPIFFS files
|
||||
***************************************************************************************/
|
||||
#ifdef ESP8266
|
||||
void listSPIFFS(void) {
|
||||
Serial.println(F("\r\nListing SPIFFS files:"));
|
||||
|
||||
fs::Dir dir = SPIFFS.openDir("/"); // Root directory
|
||||
|
||||
static const char line[] PROGMEM = "=================================================";
|
||||
Serial.println(FPSTR(line));
|
||||
Serial.println(F(" File name Size"));
|
||||
Serial.println(FPSTR(line));
|
||||
|
||||
while (dir.next()) {
|
||||
String fileName = dir.fileName();
|
||||
Serial.print(fileName);
|
||||
int spaces = 33 - fileName.length(); // Tabulate nicely
|
||||
if (spaces < 1) spaces = 1;
|
||||
while (spaces--) Serial.print(" ");
|
||||
|
||||
fs::File f = dir.openFile("r");
|
||||
String fileSize = (String) f.size();
|
||||
spaces = 10 - fileSize.length(); // Tabulate nicely
|
||||
if (spaces < 1) spaces = 1;
|
||||
while (spaces--) Serial.print(" ");
|
||||
Serial.println(fileSize + " bytes");
|
||||
}
|
||||
|
||||
Serial.println(FPSTR(line));
|
||||
Serial.println();
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
//====================================================================================
|
||||
|
||||
#elif defined ESP32
|
||||
|
||||
void listSPIFFS(void) {
|
||||
Serial.println(F("\r\nListing SPIFFS files:"));
|
||||
static const char line[] PROGMEM = "=================================================";
|
||||
|
||||
Serial.println(FPSTR(line));
|
||||
Serial.println(F(" File name Size"));
|
||||
Serial.println(FPSTR(line));
|
||||
|
||||
fs::File root = SPIFFS.open("/");
|
||||
if (!root) {
|
||||
Serial.println(F("Failed to open directory"));
|
||||
return;
|
||||
}
|
||||
if (!root.isDirectory()) {
|
||||
Serial.println(F("Not a directory"));
|
||||
return;
|
||||
}
|
||||
|
||||
fs::File file = root.openNextFile();
|
||||
while (file) {
|
||||
|
||||
if (file.isDirectory()) {
|
||||
Serial.print("DIR : ");
|
||||
String fileName = file.name();
|
||||
Serial.print(fileName);
|
||||
} else {
|
||||
String fileName = file.name();
|
||||
Serial.print(" " + fileName);
|
||||
// File path can be 31 characters maximum in SPIFFS
|
||||
int spaces = 33 - fileName.length(); // Tabulate nicely
|
||||
if (spaces < 1) spaces = 1;
|
||||
while (spaces--) Serial.print(" ");
|
||||
String fileSize = (String) file.size();
|
||||
spaces = 10 - fileSize.length(); // Tabulate nicely
|
||||
if (spaces < 1) spaces = 1;
|
||||
while (spaces--) Serial.print(" ");
|
||||
Serial.println(fileSize + " bytes");
|
||||
}
|
||||
|
||||
file = root.openNextFile();
|
||||
}
|
||||
|
||||
Serial.println(FPSTR(line));
|
||||
Serial.println();
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user