@@ -28,10 +28,11 @@ void listDir(fs::FS &fs, const char *dirname, uint8_t levels) {
2828 Serial.print (" DIR : " );
2929 Serial.print (file.name ());
3030 time_t t = file.getLastWrite ();
31- struct tm *tmstruct = localtime (&t);
31+ struct tm tmstruct;
32+ localtime_r (&t, &tmstruct);
3233 Serial.printf (
33- " LAST WRITE: %d-%02d-%02d %02d:%02d:%02d\n " , (tmstruct-> tm_year ) + 1900 , (tmstruct-> tm_mon ) + 1 , tmstruct-> tm_mday , tmstruct-> tm_hour ,
34- tmstruct-> tm_min , tmstruct-> tm_sec
34+ " LAST WRITE: %d-%02d-%02d %02d:%02d:%02d\n " , (tmstruct. tm_year ) + 1900 , (tmstruct. tm_mon ) + 1 , tmstruct. tm_mday , tmstruct. tm_hour ,
35+ tmstruct. tm_min , tmstruct. tm_sec
3536 );
3637 if (levels) {
3738 listDir (fs, file.path (), levels - 1 );
@@ -42,10 +43,11 @@ void listDir(fs::FS &fs, const char *dirname, uint8_t levels) {
4243 Serial.print (" SIZE: " );
4344 Serial.print (file.size ());
4445 time_t t = file.getLastWrite ();
45- struct tm *tmstruct = localtime (&t);
46+ struct tm tmstruct;
47+ localtime_r (&t, &tmstruct);
4648 Serial.printf (
47- " LAST WRITE: %d-%02d-%02d %02d:%02d:%02d\n " , (tmstruct-> tm_year ) + 1900 , (tmstruct-> tm_mon ) + 1 , tmstruct-> tm_mday , tmstruct-> tm_hour ,
48- tmstruct-> tm_min , tmstruct-> tm_sec
49+ " LAST WRITE: %d-%02d-%02d %02d:%02d:%02d\n " , (tmstruct. tm_year ) + 1900 , (tmstruct. tm_mon ) + 1 , tmstruct. tm_mday , tmstruct. tm_hour ,
50+ tmstruct. tm_min , tmstruct. tm_sec
4951 );
5052 }
5153 file = root.openNextFile ();
0 commit comments