-

Dependents:   RSALB_hbridge_helloworld RSALB_lobster WavPlayer_test AudioCODEC_HelloWorld ... more

Fork of FatFileSystemCpp by Igor Skochinsky

Committer:
p07gbar
Date:
Wed Sep 19 11:03:35 2012 +0000
Revision:
2:e869ee8f3c3d
Parent:
0:6ceefe1c53e4
-

Who changed what in which revision?

UserRevisionLine numberNew contents of line
p07gbar 2:e869ee8f3c3d 1 /* mbed Microcontroller Library - FATFileSystem
p07gbar 2:e869ee8f3c3d 2 * Copyright (c) 2008, sford
p07gbar 2:e869ee8f3c3d 3 */
p07gbar 2:e869ee8f3c3d 4
p07gbar 2:e869ee8f3c3d 5 /* Library: FATFileSystem.h
p07gbar 2:e869ee8f3c3d 6 * A library of stuff to make a fat filesystem on top of a block device
p07gbar 2:e869ee8f3c3d 7 */
p07gbar 2:e869ee8f3c3d 8
p07gbar 2:e869ee8f3c3d 9 #ifndef MBED_FATFILESYSTEM_H
p07gbar 2:e869ee8f3c3d 10 #define MBED_FATFILESYSTEM_H
p07gbar 2:e869ee8f3c3d 11
p07gbar 2:e869ee8f3c3d 12 #ifndef FFSDEBUG_ENABLED
p07gbar 2:e869ee8f3c3d 13 #define FFSDEBUG_ENABLED 0
p07gbar 2:e869ee8f3c3d 14 #endif
p07gbar 2:e869ee8f3c3d 15
p07gbar 2:e869ee8f3c3d 16 #if FFSDEBUG_ENABLED
p07gbar 2:e869ee8f3c3d 17 #define FFSDEBUG(FMT, ...) printf(FMT, ##__VA_ARGS__)
p07gbar 2:e869ee8f3c3d 18 #else
p07gbar 2:e869ee8f3c3d 19 #define FFSDEBUG(FMT, ...)
p07gbar 2:e869ee8f3c3d 20 #endif
p07gbar 2:e869ee8f3c3d 21
p07gbar 2:e869ee8f3c3d 22 #include "FileSystemLike.h"
p07gbar 2:e869ee8f3c3d 23 #include "FileHandle.h"
p07gbar 2:e869ee8f3c3d 24 #include "ff.h"
p07gbar 2:e869ee8f3c3d 25 #include "diskio.h"
p07gbar 2:e869ee8f3c3d 26
p07gbar 2:e869ee8f3c3d 27 namespace mbed {
p07gbar 2:e869ee8f3c3d 28 /* Class: FATFileSystem
p07gbar 2:e869ee8f3c3d 29 * The class itself
p07gbar 2:e869ee8f3c3d 30 */
p07gbar 2:e869ee8f3c3d 31 class FATFileSystem : public FileSystemLike {
p07gbar 2:e869ee8f3c3d 32 public:
p07gbar 2:e869ee8f3c3d 33
p07gbar 2:e869ee8f3c3d 34 FATFileSystem(const char* n);
p07gbar 2:e869ee8f3c3d 35 virtual ~FATFileSystem();
p07gbar 2:e869ee8f3c3d 36
p07gbar 2:e869ee8f3c3d 37 /* Function: open
p07gbar 2:e869ee8f3c3d 38 * open a file on the filesystem. never called directly
p07gbar 2:e869ee8f3c3d 39 */
p07gbar 2:e869ee8f3c3d 40 virtual FileHandle *open(const char* name, int flags);
p07gbar 2:e869ee8f3c3d 41 virtual int remove(const char *filename);
p07gbar 2:e869ee8f3c3d 42 virtual int format();
p07gbar 2:e869ee8f3c3d 43 virtual DirHandle *opendir(const char *name);
p07gbar 2:e869ee8f3c3d 44 virtual int mkdir(const char *name, mode_t mode);
p07gbar 2:e869ee8f3c3d 45
p07gbar 2:e869ee8f3c3d 46 FATFS _fs; // Work area (file system object) for logical drive
p07gbar 2:e869ee8f3c3d 47 static FATFileSystem *_ffs[_VOLUMES]; // FATFileSystem objects, as parallel to FatFs drives array
p07gbar 2:e869ee8f3c3d 48 int _fsid;
p07gbar 2:e869ee8f3c3d 49
p07gbar 2:e869ee8f3c3d 50 virtual int disk_initialize() { return 0; }
p07gbar 2:e869ee8f3c3d 51 virtual int disk_status() { return 0; }
p07gbar 2:e869ee8f3c3d 52 virtual int disk_read(char *buffer, int sector) = 0;
p07gbar 2:e869ee8f3c3d 53 virtual int disk_write(const char *buffer, int sector) = 0;
p07gbar 2:e869ee8f3c3d 54 virtual int disk_sync() { return 0; }
p07gbar 2:e869ee8f3c3d 55 virtual int disk_sectors() = 0;
p07gbar 2:e869ee8f3c3d 56
p07gbar 2:e869ee8f3c3d 57 };
p07gbar 2:e869ee8f3c3d 58
p07gbar 2:e869ee8f3c3d 59 }
p07gbar 2:e869ee8f3c3d 60
p07gbar 2:e869ee8f3c3d 61 #endif