Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ESPFlash: Open a file with a filename of “/lengthExample” and get the number of elements stored in the file with error checking.
/*
Open a file with a filename of “/lengthExample” and get the number of
elements stored in the file with error checking.
*/
ESPFlash<double> lengthExample("/lengthExample");
uint32_t numberOfElements = lengthExample.length();
/* The above code replaces the following SPIFFS implementation */
File file;
uint32_t sizeInBytes = 0;
uint32_t sizeInElements = 0;
SPIFFS.begin();
file = SPIFFS.open("/lengthExample", "r");
if(file)
{
sizeInBytes = file.size();
sizeInElements = sizeInBytes/sizeof(double);
}
file.close();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment