2018.07.26
Fork of FATFileSystem by
FATFileSystem.h@1:46ce1e16c870, 2012-11-27 (annotated)
- Committer:
- emilmont
- Date:
- Tue Nov 27 17:31:18 2012 +0000
- Revision:
- 1:46ce1e16c870
- Parent:
- 0:a846fcbeb0a2
- Child:
- 3:e960e2b81a3c
Commit FATFileSystem code
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 | |
emilmont | 1:46ce1e16c870 | 32 | class FATFileSystem : public FileSystemLike { |
emilmont | 1:46ce1e16c870 | 33 | public: |
emilmont | 1:46ce1e16c870 | 34 | |
emilmont | 1:46ce1e16c870 | 35 | FATFileSystem(const char* n); |
emilmont | 1:46ce1e16c870 | 36 | virtual ~FATFileSystem(); |
emilmont | 1:46ce1e16c870 | 37 | |
emilmont | 1:46ce1e16c870 | 38 | static FATFileSystem * _ffs[_VOLUMES]; // FATFileSystem objects, as parallel to FatFs drives array |
emilmont | 1:46ce1e16c870 | 39 | FATFS _fs; // Work area (file system object) for logical drive |
emilmont | 1:46ce1e16c870 | 40 | int _fsid; |
emilmont | 1:46ce1e16c870 | 41 | |
emilmont | 1:46ce1e16c870 | 42 | virtual FileHandle *open(const char* name, int flags); |
emilmont | 1:46ce1e16c870 | 43 | virtual int remove(const char *filename); |
emilmont | 1:46ce1e16c870 | 44 | virtual int format(); |
emilmont | 1:46ce1e16c870 | 45 | virtual DirHandle *opendir(const char *name); |
emilmont | 1:46ce1e16c870 | 46 | virtual int mkdir(const char *name, mode_t mode); |
emilmont | 1:46ce1e16c870 | 47 | |
emilmont | 1:46ce1e16c870 | 48 | virtual int disk_initialize() { return 0; } |
emilmont | 1:46ce1e16c870 | 49 | virtual int disk_status() { return 0; } |
emilmont | 1:46ce1e16c870 | 50 | virtual int disk_read(uint8_t * buffer, uint64_t sector) = 0; |
emilmont | 1:46ce1e16c870 | 51 | virtual int disk_write(const uint8_t * buffer, uint64_t sector) = 0; |
emilmont | 1:46ce1e16c870 | 52 | virtual int disk_sync() { return 0; } |
emilmont | 1:46ce1e16c870 | 53 | virtual uint64_t disk_sectors() = 0; |
emilmont | 1:46ce1e16c870 | 54 | |
emilmont | 1:46ce1e16c870 | 55 | }; |
emilmont | 1:46ce1e16c870 | 56 | |
emilmont | 1:46ce1e16c870 | 57 | #endif |