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