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