forked version of FATFileSystemEx

Fork of FATFileSystem by mbed official

Files at this revision

API Documentation at this revision

Comitter:
bkc_mbed
Date:
Wed Aug 20 00:20:41 2014 +0000
Parent:
3:e960e2b81a3c
Commit message:
added tiny mode

Changed in this revision

ChaN/ffconf.h Show annotated file Show diff for this revision Revisions of this file
FATFileHandle.cpp Show annotated file Show diff for this revision Revisions of this file
FATFileHandle.h Show annotated file Show diff for this revision Revisions of this file
FATFileSystem.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/ChaN/ffconf.h	Mon Mar 17 14:09:00 2014 +0000
+++ b/ChaN/ffconf.h	Wed Aug 20 00:20:41 2014 +0000
@@ -15,13 +15,13 @@
 / Functions and Buffer Configurations
 /----------------------------------------------------------------------------*/
 
-#define _FS_TINY        0   /* 0:Normal or 1:Tiny */
+#define _FS_TINY        1   /* 0:Normal or 1:Tiny */
 /* When _FS_TINY is set to 1, FatFs uses the sector buffer in the file system
 /  object instead of the sector buffer in the individual file object for file
 /  data transfer. This reduces memory consumption 512 bytes each file object. */
 
 
-#define _FS_READONLY    0   /* 0:Read/Write or 1:Read only */
+#define _FS_READONLY    1   /* 0:Read/Write or 1:Read only */
 /* Setting _FS_READONLY to 1 defines read only configuration. This removes
 /  writing functions, f_write, f_sync, f_unlink, f_mkdir, f_chmod, f_rename,
 /  f_truncate and useless f_getfree. */
--- a/FATFileHandle.cpp	Mon Mar 17 14:09:00 2014 +0000
+++ b/FATFileHandle.cpp	Wed Aug 20 00:20:41 2014 +0000
@@ -36,13 +36,18 @@
 }
 
 ssize_t FATFileHandle::write(const void* buffer, size_t length) {
+#ifdef FAT_TINY
+    return -1;
+#else
     UINT n;
+
     FRESULT res = f_write(&_fh, buffer, length, &n);
     if (res) { 
         debug_if(FFS_DBG, "f_write() failed: %d", res);
         return -1;
     }
     return n;
+#endif
 }
         
 ssize_t FATFileHandle::read(void* buffer, size_t length) {
@@ -77,12 +82,16 @@
 }
 
 int FATFileHandle::fsync() {
+#ifdef FAT_TINY
+    return -1;
+#else
     FRESULT res = f_sync(&_fh);
     if (res) {
         debug_if(FFS_DBG, "f_sync() failed: %d\n", res);
         return -1;
     }
     return 0;
+#endif
 }
 
 off_t FATFileHandle::flen() {
--- a/FATFileHandle.h	Mon Mar 17 14:09:00 2014 +0000
+++ b/FATFileHandle.h	Wed Aug 20 00:20:41 2014 +0000
@@ -44,4 +44,6 @@
 
 };
 
+#define FAT_TINY
+
 #endif
--- a/FATFileSystem.cpp	Mon Mar 17 14:09:00 2014 +0000
+++ b/FATFileSystem.cpp	Wed Aug 20 00:20:41 2014 +0000
@@ -28,6 +28,16 @@
 #include "FATFileHandle.h"
 #include "FATDirHandle.h"
 
+#ifdef FAT_TINY
+#define FA_RDWR FA_READ
+#define FA_WRITE FA_READ
+#define FA_CREATE_ALWAYS 0
+#define FA_OPEN_ALWAYS 0
+#else
+#define FA_RDWR (FA_READ|FA_WRITE)
+#endif
+
+
 DWORD get_fattime(void) {
     time_t rawtime;
     time(&rawtime);
@@ -73,7 +83,7 @@
     /* POSIX flags -> FatFS open mode */
     BYTE openmode;
     if (flags & O_RDWR) {
-        openmode = FA_READ|FA_WRITE;
+        openmode = FA_RDWR;
     } else if(flags & O_WRONLY) {
         openmode = FA_WRITE;
     } else {
@@ -100,21 +110,29 @@
 }
     
 int FATFileSystem::remove(const char *filename) {
+#ifdef FAT_TINY
+    return -1;
+#else
     FRESULT res = f_unlink(filename);
     if (res) { 
         debug_if(FFS_DBG, "f_unlink() failed: %d\n", res);
         return -1;
     }
     return 0;
+#endif
 }
 
 int FATFileSystem::format() {
+#ifdef FAT_TINY
+    return -1;
+#else
     FRESULT res = f_mkfs(_fsid, 0, 512); // Logical drive number, Partitioning rule, Allocation unit size (bytes per cluster)
     if (res) {
         debug_if(FFS_DBG, "f_mkfs() failed: %d\n", res);
         return -1;
     }
     return 0;
+#endif
 }
 
 DirHandle *FATFileSystem::opendir(const char *name) {
@@ -127,6 +145,10 @@
 }
 
 int FATFileSystem::mkdir(const char *name, mode_t mode) {
+#ifdef FAT_TINY
+    return -1;
+#else
     FRESULT res = f_mkdir(name);
     return res == 0 ? 0 : -1;
+#endif
 }