Fork of Adam Green's library with .cpp fix for current compiler

Dependents:   MSCUsbHost mpod_nhk_english mpod_picasa_photoframe mpod_nhk_english_spxml ... more

Fork of FatFileSystem by Adam Green

Committer:
igorsk
Date:
Mon Jul 30 13:45:05 2012 +0000
Revision:
1:88f22c32a456
Parent:
0:6ceefe1c53e4
renamed .c to .cpp

Who changed what in which revision?

UserRevisionLine numberNew 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