SPIFFS file.size() wrong on newly created file

cspwcspw
Posts: 18
Joined: Mon Apr 16, 2018 5:08 pm

SPIFFS file.size() wrong on newly created file

Postby cspwcspw » Fri Nov 16, 2018 2:53 pm

To get the file size one has to open the file and call f.size(). That works. But if opening the file also creates it, the size is wrong.

File f = SPIFFS.open("/test.txt", "a"); // this creates the file if it does not exist. Opens for appending data.
size_t sz = f.size();

f.size() works if the file already exists when opening it. But if the first line of code has to create the file, the size comes out wrong.


Peter

Who is online

Users browsing this forum: No registered users and 50 guests