FS: copy lfs_info and implement FS::Stat()

Implement the subset of the functionality to be usable to check if the
file exists or not and check the size of the file.
This commit is contained in:
Reinhold Gschweicher
2022-04-04 21:22:57 +02:00
parent d4e81ca177
commit 9f36b7886d
2 changed files with 34 additions and 1 deletions

View File

@@ -163,6 +163,16 @@ int FS::DirDelete(const char* path) {
//return LFS_ERR_OK;
}
// check if file exists, if so write file-size into info object
int FS::Stat(const char* path, lfs_info* info) {
if (!std::filesystem::exists(path))
{
return LFS_ERR_NOENT; // No directory entry
}
info->size = std::filesystem::file_size(path);
return LFS_ERR_OK;
}
/*
----------- Interface between littlefs and SpiNorFlash -----------