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