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