publication inutile mais obligée

Committer:
adrevong
Date:
Tue Jan 28 11:14:21 2020 +0000
Revision:
0:8b2a15992487

        

Who changed what in which revision?

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