Maybe something else in your code that you didn't tested properly.
Maybe something else in your code that you didn't tested properly.
Explore... Chat... Share...
I've just tested the SPIFFS.rename() and it is working properly.
Maybe something else in your code that you didn't tested properly. - See more at: posting.php?mode=reply&f=6&t=14299#sthash.w2e538AQ.dpuf
void fileStore() //If 7th day of week, rename "log.txt" to ("log" + month + day + ".txt") and create new, empty "log.txt"
{
getDateTime();
// rename the file "LOG.TXT"
String logname;
logname = "LOG";
logname += Clock.getMonth(Century);
logname += Clock.getDate();
logname += ".TXT";
SPIFFS.rename("LOG.TXT", logname.c_str());
Serial.println("Gets Here 2");
//For troubleshooting
Serial.println(logname.c_str());
// create a new "log.txt" file for appended writing
File log = SPIFFS.open("LOG.TXT", "a");
if (!log)
{
Serial.println("file open failed");
}
log.println("");
log.close();
Serial.println("");
Serial.println("New LOG.TXT created");
}
void fileStore() //If 7th day of week, rename "log.txt" to ("log" + month + day + ".txt") and create new, empty "log.txt"
{
// create a file and write one line to the file
SdFile logFile("log.txt", O_WRITE | O_CREAT );
if (!logFile.isOpen())
{
error("log.txt --new -open");
}
// rename the file log.txt
// sd.vwd() is the volume working directory, root.
logFileName = "";
logFileName = "log";
logFileName += (RTCTimedEvent.time.month);
logFileName += (RTCTimedEvent.time.day);
logFileName += ".txt";
//Serial.println(logFileName.c_str());
if(sd.exists("log.txt"))
{
logFile.rename(sd.vwd(), logFileName.c_str());
logFile.close();
}
else
{
exit;
}
// create a new "log.txt" file for appended writing
logFile.open("log.txt", O_WRITE | O_CREAT | O_APPEND);
logFile.println("");
logFile.close();
Serial.begin(115200);
Serial.println("");
Serial.println("New LOG.TXT created");
// list files
cout << pstr("------") << endl;
sd.ls(LS_R);
Serial.flush();
Serial.end();
}
It takes about 20-25 seconds for home assistant c[…]
I tried to upgrade tof my sonoff basic R2 with the[…]
a problem Perhaps you want to define "Probl[…]
Rebooting your router will not give you a faster I[…]
There are no other notifications from esptool.py i[…]
Using the Arduino IDE, you'll learn how to set up […]
In this project, you will post to Twitter using an[…]
In this project, we will build a water level contr[…]
I guess I'm late, but I had the same problem and f[…]
Last night I received my first D1 Minis for a lear[…]
Although I am aware that this is an old post, I fe[…]