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