[x] The code changes are reflected in the documentation at docs/*. no doc changes necessary
The modern spiffs backend doesn't like stat("./somefile") for something on the root of the filesystem, and instead only accepts "somefile" (it also doesn't like "/somefile"). The error from stat was being ignored which is why the file sizes all appeared to be zero. I don't know why spiffs is so picky... mumbles something about mount points.
The fix is to change file.list() to pass just the filename into the stat() call, unless a directory was passed to list() in which case do what we used to do and prepend the dir name. Also improved error handling so we call closedir if we error. I also changed the opendir to open "/" rather than ".", but since we don't expose any way to change cwd I don't think it matters either way, but I felt it was a bit clearer to use "/".
Tested on esp32s2 with dev-esp32-idf4 @ d8f07ddf90a278abb77a5247d4ce34201de9e56d
I have tested this PR on ESP32 Devkitc_v4. file.list() now returns proper size both for files on spiffs and for files on mounted volumes of eromfs module.
Thank you!
Fixes #3549
dev
branch rather than for therelease
branch.docs/*
. no doc changes necessaryThe modern spiffs backend doesn't like
stat("./somefile")
for something on the root of the filesystem, and instead only accepts"somefile"
(it also doesn't like"/somefile"
). The error from stat was being ignored which is why the file sizes all appeared to be zero. I don't know why spiffs is so picky... mumbles something about mount points.The fix is to change file.list() to pass just the filename into the stat() call, unless a directory was passed to list() in which case do what we used to do and prepend the dir name. Also improved error handling so we call closedir if we error. I also changed the opendir to open "/" rather than ".", but since we don't expose any way to change cwd I don't think it matters either way, but I felt it was a bit clearer to use "/".
Tested on esp32s2 with dev-esp32-idf4 @ d8f07ddf90a278abb77a5247d4ce34201de9e56d