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