Description
Related area
vfs_api
Hardware specification
ESP32
Is your feature request related to a problem?
Describe the solution you'd like
In vfs_api.cpp FileImplPtr VFSImpl::open(...) calls stat, which is pretty slow with LittleFS or SPIFFS. After that succeeded open returns
return std::make_shared<VFSFileImpl>(this, path, mode);
VFSFileImpl constructor calls again stat. I made experimental new constructor, which gets stat structure and full path:
VFSFileImpl(VFSImpl* fs, const struct stat &st, const char* fpath, const char* path, const char* mode);
then instead of original constructor I call
if (S_ISREG(st.st_mode) || S_ISDIR(st.st_mode)) {
FileImplPtr ret=std::make_shared<VFSFileImpl>(this, st, temp, path, mode);
free(temp);
return ret;
}
...
Since new constructor gets stat structure from caller, it does not need to call it again and so my open times are half of original. Currently I use that constructor only for existing files, but if new constructor would also get stat result as parameter, it could be used also for new files:
VFSFileImpl(VFSImpl* fs, const struct stat &st, int statResult, const char* fpath, const char* path, const char* mode);
Do you find any problem using open in this way?
Describe alternatives you've considered
No response
Additional context
No response
I have checked existing list of Feature requests and the Contribution Guide
- I confirm I have checked existing list of Feature requests and Contribution Guide.
Metadata
Metadata
Assignees
Type
Projects
Status