Created
June 10, 2020 10:03
-
-
Save DaleGia/294357ac8ca5d3f534db0b449d58f545 to your computer and use it in GitHub Desktop.
ESPFlash: Open a file with a filename of “/lengthExample” and get the number of elements stored in the file with error checking.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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