2424#include < functional>
2525#include < cstdint>
2626#include < memory>
27+ #include < map>
2728
2829namespace fs
2930{
@@ -32,24 +33,26 @@ namespace fs
3233 struct FAT : public FileSystem
3334 {
3435 // / ----------------------------------------------------- ///
35- virtual void mount (uint64_t lba, uint64_t size, on_mount_func on_mount) override ;
36+ void mount (uint64_t lba, uint64_t size, on_mount_func on_mount) override ;
3637
3738 // path is a path in the mounted filesystem
38- virtual void ls (const std::string& path, on_ls_func) override ;
39- virtual void ls (const Dirent& entry, on_ls_func) override ;
40- virtual List ls (const std::string& path) override ;
41- virtual List ls (const Dirent&) override ;
39+ void ls (const std::string& path, on_ls_func) override ;
40+ void ls (const Dirent& entry, on_ls_func) override ;
41+ List ls (const std::string& path) override ;
42+ List ls (const Dirent&) override ;
4243
4344 /* * Read @n bytes from file pointed by @entry starting at position @pos */
44- virtual void read (const Dirent&, uint64_t pos, uint64_t n, on_read_func) override ;
45- virtual Buffer read (const Dirent&, uint64_t pos, uint64_t n) override ;
45+ void read (const Dirent&, uint64_t pos, uint64_t n, on_read_func) override ;
46+ Buffer read (const Dirent&, uint64_t pos, uint64_t n) override ;
4647
4748 // return information about a filesystem entity
48- virtual void stat (const std::string&, on_stat_func) override ;
49- virtual Dirent stat (const std::string& ent) override ;
49+ void stat (const std::string&, on_stat_func) override ;
50+ Dirent stat (const std::string& ent) override ;
51+ // async cached stat
52+ void cstat (const std::string&, on_stat_func) override ;
5053
5154 // returns the name of the filesystem
52- virtual std::string name () const override
55+ std::string name () const override
5356 {
5457 switch (this ->fat_type )
5558 {
@@ -91,7 +94,7 @@ namespace fs
9194 uint8_t attrib;
9295 uint8_t pad1[8 ];
9396 uint16_t cluster_hi;
94- uint8_t pad2[ 4 ] ;
97+ uint32_t modified ;
9598 uint16_t cluster_lo;
9699 uint32_t filesize;
97100
@@ -210,6 +213,9 @@ namespace fs
210213 uint32_t root_cluster; // index of root cluster
211214 uint32_t data_index; // index of first data sector (relative to partition)
212215 uint32_t data_sectors; // number of data sectors
216+
217+ // simplistic cache for stat results
218+ std::map<std::string, FileSystem::Dirent> stat_cache;
213219 };
214220
215221} // fs
0 commit comments