My fork of the FATFileSystem (working)

Dependents:   DGWWebServer

Fork of FatFileSystem by mbed unsupported

Committer:
screamer
Date:
Tue Nov 20 12:19:46 2012 +0000
Revision:
4:a3c0bfc113b2
Parent:
0:97df4125f18d
Documented FATFileSystem class and open method

Who changed what in which revision?

UserRevisionLine numberNew 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 {
screamer 4:a3c0bfc113b2 28 /** FATFileSystem
screamer 4:a3c0bfc113b2 29 * The class itself
screamer 4:a3c0bfc113b2 30 */
mbed_unsupported 0:97df4125f18d 31 class FATFileSystem : public FileSystemLike {
mbed_unsupported 0:97df4125f18d 32 public:
mbed_unsupported 0:97df4125f18d 33
screamer 4:a3c0bfc113b2 34 FATFileSystem(const char* n);
screamer 4:a3c0bfc113b2 35 virtual ~FATFileSystem();
screamer 4:a3c0bfc113b2 36
screamer 4:a3c0bfc113b2 37 /** open
screamer 4:a3c0bfc113b2 38 * open a file on the filesystem. never called directly
screamer 4:a3c0bfc113b2 39 */
screamer 4:a3c0bfc113b2 40 virtual FileHandle *open(const char* name, int flags);
screamer 4:a3c0bfc113b2 41 virtual int remove(const char *filename);
screamer 4:a3c0bfc113b2 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);
screamer 4:a3c0bfc113b2 45
screamer 4:a3c0bfc113b2 46 FATFS _fs; // Work area (file system object) for logical drive
screamer 4:a3c0bfc113b2 47 static FATFileSystem *_ffs[_DRIVES]; // FATFileSystem objects, as parallel to FatFs drives array
screamer 4:a3c0bfc113b2 48 int _fsid;
screamer 4:a3c0bfc113b2 49
screamer 4:a3c0bfc113b2 50 virtual int disk_initialize() { return 0; }
screamer 4:a3c0bfc113b2 51 virtual int disk_status() { return 0; }
screamer 4:a3c0bfc113b2 52 virtual int disk_read(char *buffer, int sector) = 0;
screamer 4:a3c0bfc113b2 53 virtual int disk_write(const char *buffer, int sector) = 0;
screamer 4:a3c0bfc113b2 54 virtual int disk_sync() { return 0; }
screamer 4:a3c0bfc113b2 55 virtual int disk_sectors() = 0;
screamer 4:a3c0bfc113b2 56
mbed_unsupported 0:97df4125f18d 57 };
screamer 4:a3c0bfc113b2 58
mbed_unsupported 0:97df4125f18d 59 }
mbed_unsupported 0:97df4125f18d 60
mbed_unsupported 0:97df4125f18d 61 #endif