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);
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);
}
file=root.openNextFile();
}
}
voidcreateDir(fs::FS&fs,constchar*path){
Serial.printf("Creating Dir: %s\n",path);
if(fs.mkdir(path)){
Serial.println("Dir created");
}else{
Serial.println("mkdir failed");
}
}
voidremoveDir(fs::FS&fs,constchar*path){
Serial.printf("Removing Dir: %s\n",path);
if(fs.rmdir(path)){
Serial.println("Dir removed");
}else{
Serial.println("rmdir failed");
}
}
voidreadFile(fs::FS&fs,constchar*path){
Serial.printf("Reading file: %s\n",path);
Filefile=fs.open(path);
if(!file){
Serial.println("Failed to open file for reading");
Serial.printf("\nNow is : %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);
Serial.println("");
if(!SPIFFS.begin(FORMAT_LITTLEFS_IF_FAILED)){
Serial.println("LITTLEFS Mount Failed");
return;
}
Serial.println("----list 1----");
listDir(SPIFFS,"/",1);
Serial.println("----remove old dir----");
removeDir(SPIFFS,"/mydir");
Serial.println("----create a new dir----");
createDir(SPIFFS,"/mydir");
Serial.println("----remove the new dir----");
removeDir(SPIFFS,"/mydir");
Serial.println("----create the new again----");
createDir(SPIFFS,"/mydir");
Serial.println("----create and work with file----");
writeFile(SPIFFS,"/mydir/hello.txt","Hello ");
appendFile(SPIFFS,"/mydir/hello.txt","World!\n");
Serial.println("----list 2----");
listDir(SPIFFS,"/",1);
Serial.println("----attempt to remove dir w/ file----");
removeDir(SPIFFS,"/mydir");
Serial.println("----remove dir after deleting file----");