-->
Page 1 of 1

SPIFFS file wrong dimension!

PostPosted: Tue Jul 12, 2016 9:44 am
by pbecchi
I am using SPIFFS file system for logging data.
Sometimes when I re open an existing file a find a wrong file length: :o

More precisely :
I open this way:
if (SPIFFS.exists("/weather.log"))
wfile = SPIFFS.open("/weather.log", "r+");
else
wfile = SPIFFS.open("/weather.log", "w+");

if (!wfile) {
Serial.println("Cannot open weather.log"); return 0;
}

...if I read the file sequentially a find the EOF char before I get to the position defined by the end of the file:

file.seek(0,SeekEnd);
long EndOfFilePosition=file.position();

If I read sequentially this way:

while( file.available()) file.read();

The program run forever!

If I try to append to this file ....all the record appended are lost!

There is any way to avoid this error end to recover the file with the wrong length?