Hi all,
I’m writing to the filesystem and want to check the file size using stat method (https://docs.particle.io/reference/device-os/firmware/boron/#file-system-stat )
If the file doesnt exist, it returns the -1, but if it exists it seems to show the same size of the file: 1591.
Code is like this:
success = stat(FILE_NAME, fileStatBuffer);
Log.info (“File stat success %d”, success);
if (success != -1)
{
success = (int)(fileStatBuffer->st_size);
Log.info (“File size %d”, success);
}
Note that the declaration of struct stat is not a *; you need to allocate the actual structure but the use &sb as the parameter because stat takes a pointer to the structure you allocated.