Fork of FATFileSystem that exposes FILINFO in the FATDirHandle. This allows obtaining true file sizes and testing whether a dir pointer is a directory or a file.

Dependents:   SDFileSystemNoStall

Fork of FATFileSystem by mbed official

Revision:
6:7a3c53d25d96
Parent:
4:3ff2606d5713
--- a/FATFileSystem.cpp	Thu Oct 30 06:19:16 2014 +0000
+++ b/FATFileSystem.cpp	Thu Oct 30 07:01:15 2014 +0000
@@ -69,7 +69,7 @@
     debug_if(FFS_DBG, "open(%s) on filesystem [%s], drv [%d]\n", name, _name, _fsid);
     char n[64];
     sprintf(n, "%d:/%s", _fsid, name);
-
+    
     /* POSIX flags -> FatFS open mode */
     BYTE openmode;
     if (flags & O_RDWR) {
@@ -86,10 +86,10 @@
             openmode |= FA_OPEN_ALWAYS;
         }
     }
-
+    
     FIL fh;
     FRESULT res = f_open(&fh, n, openmode);
-    if (res) {
+    if (res) { 
         debug_if(FFS_DBG, "f_open('w') failed: %d\n", res);
         return NULL;
     }
@@ -98,25 +98,16 @@
     }
     return new FATFileHandle(fh);
 }
-
+    
 int FATFileSystem::remove(const char *filename) {
     FRESULT res = f_unlink(filename);
-    if (res) {
+    if (res) { 
         debug_if(FFS_DBG, "f_unlink() failed: %d\n", res);
         return -1;
     }
     return 0;
 }
 
-int FATFileSystem::rename(const char *oldname, const char *newname) {
-    FRESULT res = f_rename(oldname, newname);
-    if (res) {
-        debug_if(FFS_DBG, "f_rename() failed: %d\n", res);
-        return -1;
-    }
-    return 0;
-}
-
 int FATFileSystem::format() {
     FRESULT res = f_mkfs(_fsid, 0, 512); // Logical drive number, Partitioning rule, Allocation unit size (bytes per cluster)
     if (res) {
@@ -139,15 +130,3 @@
     FRESULT res = f_mkdir(name);
     return res == 0 ? 0 : -1;
 }
-
-int FATFileSystem::mount() {
-    FRESULT res = f_mount(_fsid, &_fs);
-    return res == 0 ? 0 : -1;
-}
-
-int FATFileSystem::unmount() {
-    if (disk_sync())
-        return -1;
-    FRESULT res = f_mount(_fsid, NULL);
-    return res == 0 ? 0 : -1;
-}