FATFileSystem
Fork of FATFileSystem by
Revision 10:28e685e5ff7f, committed 2017-07-10
- Comitter:
- geky
- Date:
- Mon Jul 10 15:37:41 2017 +0000
- Parent:
- 9:e2ab678eb692
- Commit message:
- Added stubs for FileSystemLike updates
Changed in this revision
diff -r e2ab678eb692 -r 28e685e5ff7f FATDirHandle.cpp --- a/FATDirHandle.cpp Sat Jul 30 20:47:51 2016 +0000 +++ b/FATDirHandle.cpp Mon Jul 10 15:37:41 2017 +0000 @@ -77,3 +77,13 @@ dir.index = location; } +ssize_t FATDirHandle::read(struct dirent *ent) { + struct dirent *temp = readdir(); + if (!temp) { + return 0; + } + + memcpy(ent, temp, sizeof(*ent)); + return 1; +} +
diff -r e2ab678eb692 -r 28e685e5ff7f FATDirHandle.h --- a/FATDirHandle.h Sat Jul 30 20:47:51 2016 +0000 +++ b/FATDirHandle.h Mon Jul 10 15:37:41 2017 +0000 @@ -36,6 +36,12 @@ virtual off_t telldir(); virtual void seekdir(off_t location); + virtual ssize_t read(struct dirent *ent); + virtual int close() { return closedir(); }; + virtual void seek(off_t offset) { seekdir(offset); }; + virtual off_t tell() { return telldir(); }; + virtual void rewind() { rewinddir(); }; + private: FATFS_DIR dir; struct dirent cur_entry;
diff -r e2ab678eb692 -r 28e685e5ff7f FATFileHandle.h --- a/FATFileHandle.h Sat Jul 30 20:47:51 2016 +0000 +++ b/FATFileHandle.h Mon Jul 10 15:37:41 2017 +0000 @@ -37,9 +37,12 @@ virtual off_t lseek(off_t position, int whence); virtual int fsync(); virtual off_t flen(); + + virtual off_t seek(off_t position, int whence) { return lseek(position, whence); } + virtual off_t size() { return flen(); } protected: - + FIL _fh; };
diff -r e2ab678eb692 -r 28e685e5ff7f FATFileSystem.cpp --- a/FATFileSystem.cpp Sat Jul 30 20:47:51 2016 +0000 +++ b/FATFileSystem.cpp Mon Jul 10 15:37:41 2017 +0000 @@ -100,6 +100,16 @@ return new FATFileHandle(fh); } +int FATFileSystem::open(FileHandle **file, const char *name, int flags) { + FileHandle *temp = open(name, flags); + if (!temp) { + return -1; + } + + *file = temp; + return 0; +} + int FATFileSystem::remove(const char *filename) { FRESULT res = f_unlink(filename); if (res) { @@ -136,6 +146,16 @@ return new FATDirHandle(dir); } +int FATFileSystem::open(DirHandle **dir, const char *name) { + DirHandle *temp = opendir(name); + if (!temp) { + return -1; + } + + *dir = temp; + return 0; +} + int FATFileSystem::mkdir(const char *name, mode_t mode) { FRESULT res = f_mkdir(name); return res == 0 ? 0 : -1;
diff -r e2ab678eb692 -r 28e685e5ff7f FATFileSystem.h --- a/FATFileSystem.h Sat Jul 30 20:47:51 2016 +0000 +++ b/FATFileSystem.h Mon Jul 10 15:37:41 2017 +0000 @@ -46,6 +46,7 @@ * Opens a file on the filesystem */ virtual FileHandle *open(const char* name, int flags); + virtual int open(FileHandle **file, const char *name, int flags); /** * Removes a file path @@ -66,6 +67,7 @@ * Opens a directory on the filesystem */ virtual DirHandle *opendir(const char *name); + virtual int open(DirHandle **dir, const char *name); /** * Creates a directory path