my version
Fork of FATFileSystem by
FATFileSystem.h@3:e960e2b81a3c, 2014-03-17 (annotated)
- Committer:
- screamer
- Date:
- Mon Mar 17 14:09:00 2014 +0000
- Revision:
- 3:e960e2b81a3c
- Parent:
- 1:46ce1e16c870
- Child:
- 4:3ff2606d5713
Added code documentation and fixed compile warning
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
emilmont | 1:46ce1e16c870 | 1 | /* mbed Microcontroller Library |
emilmont | 1:46ce1e16c870 | 2 | * Copyright (c) 2006-2012 ARM Limited |
emilmont | 1:46ce1e16c870 | 3 | * |
emilmont | 1:46ce1e16c870 | 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
emilmont | 1:46ce1e16c870 | 5 | * of this software and associated documentation files (the "Software"), to deal |
emilmont | 1:46ce1e16c870 | 6 | * in the Software without restriction, including without limitation the rights |
emilmont | 1:46ce1e16c870 | 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
emilmont | 1:46ce1e16c870 | 8 | * copies of the Software, and to permit persons to whom the Software is |
emilmont | 1:46ce1e16c870 | 9 | * furnished to do so, subject to the following conditions: |
emilmont | 1:46ce1e16c870 | 10 | * |
emilmont | 1:46ce1e16c870 | 11 | * The above copyright notice and this permission notice shall be included in |
emilmont | 1:46ce1e16c870 | 12 | * all copies or substantial portions of the Software. |
emilmont | 1:46ce1e16c870 | 13 | * |
emilmont | 1:46ce1e16c870 | 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
emilmont | 1:46ce1e16c870 | 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
emilmont | 1:46ce1e16c870 | 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
emilmont | 1:46ce1e16c870 | 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
emilmont | 1:46ce1e16c870 | 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
emilmont | 1:46ce1e16c870 | 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
emilmont | 1:46ce1e16c870 | 20 | * SOFTWARE. |
emilmont | 1:46ce1e16c870 | 21 | */ |
emilmont | 1:46ce1e16c870 | 22 | #ifndef MBED_FATFILESYSTEM_H |
emilmont | 1:46ce1e16c870 | 23 | #define MBED_FATFILESYSTEM_H |
emilmont | 1:46ce1e16c870 | 24 | |
emilmont | 1:46ce1e16c870 | 25 | #include "FileSystemLike.h" |
emilmont | 1:46ce1e16c870 | 26 | #include "FileHandle.h" |
emilmont | 1:46ce1e16c870 | 27 | #include "ff.h" |
emilmont | 1:46ce1e16c870 | 28 | #include <stdint.h> |
emilmont | 1:46ce1e16c870 | 29 | |
emilmont | 1:46ce1e16c870 | 30 | using namespace mbed; |
emilmont | 1:46ce1e16c870 | 31 | |
screamer | 3:e960e2b81a3c | 32 | /** |
screamer | 3:e960e2b81a3c | 33 | * FATFileSystem based on ChaN's Fat Filesystem library v0.8 |
screamer | 3:e960e2b81a3c | 34 | */ |
emilmont | 1:46ce1e16c870 | 35 | class FATFileSystem : public FileSystemLike { |
emilmont | 1:46ce1e16c870 | 36 | public: |
emilmont | 1:46ce1e16c870 | 37 | |
emilmont | 1:46ce1e16c870 | 38 | FATFileSystem(const char* n); |
emilmont | 1:46ce1e16c870 | 39 | virtual ~FATFileSystem(); |
emilmont | 1:46ce1e16c870 | 40 | |
emilmont | 1:46ce1e16c870 | 41 | static FATFileSystem * _ffs[_VOLUMES]; // FATFileSystem objects, as parallel to FatFs drives array |
emilmont | 1:46ce1e16c870 | 42 | FATFS _fs; // Work area (file system object) for logical drive |
emilmont | 1:46ce1e16c870 | 43 | int _fsid; |
screamer | 3:e960e2b81a3c | 44 | |
screamer | 3:e960e2b81a3c | 45 | /** |
screamer | 3:e960e2b81a3c | 46 | * Opens a file on the filesystem |
screamer | 3:e960e2b81a3c | 47 | */ |
emilmont | 1:46ce1e16c870 | 48 | virtual FileHandle *open(const char* name, int flags); |
screamer | 3:e960e2b81a3c | 49 | |
screamer | 3:e960e2b81a3c | 50 | /** |
screamer | 3:e960e2b81a3c | 51 | * Removes a file path |
screamer | 3:e960e2b81a3c | 52 | */ |
emilmont | 1:46ce1e16c870 | 53 | virtual int remove(const char *filename); |
screamer | 3:e960e2b81a3c | 54 | |
screamer | 3:e960e2b81a3c | 55 | /** |
screamer | 3:e960e2b81a3c | 56 | * Formats a logical drive, FDISK artitioning rule, 512 bytes per cluster |
screamer | 3:e960e2b81a3c | 57 | */ |
emilmont | 1:46ce1e16c870 | 58 | virtual int format(); |
screamer | 3:e960e2b81a3c | 59 | |
screamer | 3:e960e2b81a3c | 60 | /** |
screamer | 3:e960e2b81a3c | 61 | * Opens a directory on the filesystem |
screamer | 3:e960e2b81a3c | 62 | */ |
emilmont | 1:46ce1e16c870 | 63 | virtual DirHandle *opendir(const char *name); |
screamer | 3:e960e2b81a3c | 64 | |
screamer | 3:e960e2b81a3c | 65 | /** |
screamer | 3:e960e2b81a3c | 66 | * Creates a directory path |
screamer | 3:e960e2b81a3c | 67 | */ |
emilmont | 1:46ce1e16c870 | 68 | virtual int mkdir(const char *name, mode_t mode); |
emilmont | 1:46ce1e16c870 | 69 | |
emilmont | 1:46ce1e16c870 | 70 | virtual int disk_initialize() { return 0; } |
emilmont | 1:46ce1e16c870 | 71 | virtual int disk_status() { return 0; } |
emilmont | 1:46ce1e16c870 | 72 | virtual int disk_read(uint8_t * buffer, uint64_t sector) = 0; |
emilmont | 1:46ce1e16c870 | 73 | virtual int disk_write(const uint8_t * buffer, uint64_t sector) = 0; |
emilmont | 1:46ce1e16c870 | 74 | virtual int disk_sync() { return 0; } |
emilmont | 1:46ce1e16c870 | 75 | virtual uint64_t disk_sectors() = 0; |
emilmont | 1:46ce1e16c870 | 76 | |
emilmont | 1:46ce1e16c870 | 77 | }; |
emilmont | 1:46ce1e16c870 | 78 | |
emilmont | 1:46ce1e16c870 | 79 | #endif |