old FATFilesystem

Dependents:   SDFileSystem

Fork of FatFileSystem by mbed unsupported

Committer:
cwang365
Date:
Wed Mar 06 00:30:59 2013 +0000
Revision:
4:af33732dbdc7
Parent:
0:97df4125f18d
lab3-news_reader

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