hhhhhhhhh

Fork of FATFileSystem by mbed official

Revision:
4:3ff2606d5713
Parent:
2:b6669c987c8e
Child:
6:b3b3370574cf
--- a/FATFileSystem.cpp	Mon Mar 17 14:09:00 2014 +0000
+++ b/FATFileSystem.cpp	Thu Aug 28 13:15:31 2014 +0100
@@ -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,16 +98,25 @@
     }
     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) {
@@ -130,3 +139,15 @@
     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;
+}