feat: started game design
This commit is contained in:
@@ -21,17 +21,17 @@
|
||||
|
||||
void listDir(fs::FS &fs, const char *dirname, uint8_t levels)
|
||||
{
|
||||
Serial.printf("Listing directory: %s\r\n", dirname);
|
||||
log_i("Listing directory: %s\r\n", dirname);
|
||||
|
||||
File root = fs.open(dirname);
|
||||
if (!root)
|
||||
{
|
||||
Serial.println("- failed to open directory");
|
||||
log_e("- failed to open directory");
|
||||
return;
|
||||
}
|
||||
if (!root.isDirectory())
|
||||
{
|
||||
Serial.println(" - not a directory");
|
||||
log_e(" - not a directory");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -40,15 +40,14 @@ void listDir(fs::FS &fs, const char *dirname, uint8_t levels)
|
||||
{
|
||||
if (file.isDirectory())
|
||||
{
|
||||
Serial.print(" DIR : ");
|
||||
log_i(" DIR : ");
|
||||
|
||||
#ifdef CONFIG_LITTLEFS_FOR_IDF_3_2
|
||||
Serial.println(file.name());
|
||||
#else
|
||||
Serial.print(file.name());
|
||||
time_t t = file.getLastWrite();
|
||||
struct tm *tmstruct = localtime(&t);
|
||||
Serial.printf(" 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);
|
||||
log_i("FILE: %s LAST WRITE: %d-%02d-%02d %02d:%02d:%02d\n",file.name(), (tmstruct->tm_year) + 1900, (tmstruct->tm_mon) + 1, tmstruct->tm_mday, tmstruct->tm_hour, tmstruct->tm_min, tmstruct->tm_sec);
|
||||
#endif
|
||||
|
||||
if (levels)
|
||||
@@ -58,17 +57,13 @@ void listDir(fs::FS &fs, const char *dirname, uint8_t levels)
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.print(" FILE: ");
|
||||
Serial.print(file.name());
|
||||
Serial.print(" SIZE: ");
|
||||
|
||||
#ifdef CONFIG_LITTLEFS_FOR_IDF_3_2
|
||||
Serial.println(file.size());
|
||||
#else
|
||||
Serial.print(file.size());
|
||||
time_t t = file.getLastWrite();
|
||||
struct tm *tmstruct = localtime(&t);
|
||||
Serial.printf(" 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);
|
||||
log_i(" FILE: %s, SIZE: %d LAST WRITE: %d-%02d-%02d %02d:%02d:%02d" ,file.name(), file.size(), (tmstruct->tm_year) + 1900, (tmstruct->tm_mon) + 1, tmstruct->tm_mday, tmstruct->tm_hour, tmstruct->tm_min, tmstruct->tm_sec);
|
||||
#endif
|
||||
}
|
||||
file = root.openNextFile();
|
||||
@@ -78,16 +73,16 @@ void listDir(fs::FS &fs, const char *dirname, uint8_t levels)
|
||||
|
||||
void readFile(fs::FS &fs, const char *path)
|
||||
{
|
||||
Serial.printf("Reading file: %s\r\n", path);
|
||||
log_i("Reading file: %s\r\n", path);
|
||||
|
||||
File file = fs.open(path);
|
||||
if (!file || file.isDirectory())
|
||||
{
|
||||
Serial.println("- failed to open file for reading");
|
||||
log_e("- failed to open file for reading");
|
||||
return;
|
||||
}
|
||||
|
||||
Serial.println("- read from file:");
|
||||
log_i("- read from file:");
|
||||
while (file.available())
|
||||
{
|
||||
Serial.write(file.read());
|
||||
@@ -99,7 +94,7 @@ void initStorage()
|
||||
{
|
||||
if (!LITTLEFS.begin(FORMAT_LITTLEFS_IF_FAILED))
|
||||
{
|
||||
Serial.println("LITTLEFS Mount Failed");
|
||||
log_e("LITTLEFS Mount Failed");
|
||||
return;
|
||||
}
|
||||
listDir(LITTLEFS, "/", 0);
|
||||
|
||||
Reference in New Issue
Block a user