jkent / frogfs

Fast Read-Only General-purpose File System (ESP-IDF and ESP8266_RTOS_SDK compatible)
https://frogfs.readthedocs.io
Mozilla Public License 2.0
25 stars 32 forks source link

get file size #5

Closed phatpaul closed 5 years ago

phatpaul commented 5 years ago

Would be nice to have a get file size method in espfs

Also fill-out the VFS layer so that this works:

size_t getFilesize(const char* filename) {
    struct stat st;
    stat(filename, &st);
    return st.st_size;
}

Anyway, It's a low priority feature that I'm going to work-around for now. This method works:

fseek(f, 0, SEEK_END); // seek to end of file
size = ftell(f); // get current file pointer
fseek(f, 0, SEEK_SET); // seek back to beginning of file
// proceed with allocating memory and reading the file