it's fat!

Fork of FATFileSystem by mbed official

Committer:
bwang
Date:
Wed Apr 18 12:25:04 2018 +0000
Revision:
11:f430519973b0
Parent:
10:28e685e5ff7f
timestamp modified to return 0, as this version of the board has no RTC

Who changed what in which revision?

UserRevisionLine numberNew 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 /**
mbed_official 4:3ff2606d5713 33 * FATFileSystem based on ChaN's Fat Filesystem library v0.8
mbed_official 4:3ff2606d5713 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
mbed_official 5:b3b3370574cf 43 char _fsid[2];
mbed_official 4:3ff2606d5713 44
screamer 3:e960e2b81a3c 45 /**
mbed_official 4:3ff2606d5713 46 * Opens a file on the filesystem
mbed_official 4:3ff2606d5713 47 */
emilmont 1:46ce1e16c870 48 virtual FileHandle *open(const char* name, int flags);
geky 10:28e685e5ff7f 49 virtual int open(FileHandle **file, const char *name, int flags);
screamer 3:e960e2b81a3c 50
screamer 3:e960e2b81a3c 51 /**
screamer 3:e960e2b81a3c 52 * Removes a file path
screamer 3:e960e2b81a3c 53 */
emilmont 1:46ce1e16c870 54 virtual int remove(const char *filename);
mbed_official 4:3ff2606d5713 55
mbed_official 4:3ff2606d5713 56 /**
mbed_official 4:3ff2606d5713 57 * Renames a file
mbed_official 4:3ff2606d5713 58 */
mbed_official 4:3ff2606d5713 59 virtual int rename(const char *oldname, const char *newname);
mbed_official 4:3ff2606d5713 60
screamer 3:e960e2b81a3c 61 /**
screamer 3:e960e2b81a3c 62 * Formats a logical drive, FDISK artitioning rule, 512 bytes per cluster
screamer 3:e960e2b81a3c 63 */
emilmont 1:46ce1e16c870 64 virtual int format();
mbed_official 4:3ff2606d5713 65
screamer 3:e960e2b81a3c 66 /**
mbed_official 4:3ff2606d5713 67 * Opens a directory on the filesystem
mbed_official 4:3ff2606d5713 68 */
emilmont 1:46ce1e16c870 69 virtual DirHandle *opendir(const char *name);
geky 10:28e685e5ff7f 70 virtual int open(DirHandle **dir, const char *name);
screamer 3:e960e2b81a3c 71
screamer 3:e960e2b81a3c 72 /**
screamer 3:e960e2b81a3c 73 * Creates a directory path
screamer 3:e960e2b81a3c 74 */
emilmont 1:46ce1e16c870 75 virtual int mkdir(const char *name, mode_t mode);
mbed_official 4:3ff2606d5713 76
mbed_official 4:3ff2606d5713 77 /**
mbed_official 4:3ff2606d5713 78 * Mounts the filesystem
mbed_official 4:3ff2606d5713 79 */
mbed_official 4:3ff2606d5713 80 virtual int mount();
mbed_official 4:3ff2606d5713 81
mbed_official 4:3ff2606d5713 82 /**
mbed_official 4:3ff2606d5713 83 * Unmounts the filesystem
mbed_official 4:3ff2606d5713 84 */
mbed_official 4:3ff2606d5713 85 virtual int unmount();
emilmont 1:46ce1e16c870 86
emilmont 1:46ce1e16c870 87 virtual int disk_initialize() { return 0; }
emilmont 1:46ce1e16c870 88 virtual int disk_status() { return 0; }
mbed_official 7:094f84646b9f 89 virtual int disk_read(uint8_t *buffer, uint32_t sector, uint32_t count) = 0;
mbed_official 7:094f84646b9f 90 virtual int disk_write(const uint8_t *buffer, uint32_t sector, uint32_t count) = 0;
emilmont 1:46ce1e16c870 91 virtual int disk_sync() { return 0; }
mbed_official 7:094f84646b9f 92 virtual uint32_t disk_sectors() = 0;
emilmont 1:46ce1e16c870 93
emilmont 1:46ce1e16c870 94 };
emilmont 1:46ce1e16c870 95
emilmont 1:46ce1e16c870 96 #endif