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