First working version of a FATFileSystem compatible Chan FAT v0.8 implementation. This is intended to use with long file names and RTOS support. For now long file names work but RTOS support is still untested.

Dependents:   USB_MSC USB_CDC_MSD_Hello TFTPServerTest DMXStation ... more

Committer:
NeoBelerophon
Date:
Fri Feb 04 21:14:33 2011 +0000
Revision:
2:629e4be333f3
Parent:
0:8ea634413549
getdir() did not work -> remove

Who changed what in which revision?

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