help :(
Dependencies: FFT
mbed/drivers/FileSystemLike.h@11:951bbb0385aa, 2020-12-04 (annotated)
- Committer:
- dimitryjl23
- Date:
- Fri Dec 04 18:01:22 2020 +0000
- Revision:
- 11:951bbb0385aa
- Parent:
- 0:d6c9b09b4042
Final :)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
annieluo2 | 0:d6c9b09b4042 | 1 | /* mbed Microcontroller Library |
annieluo2 | 0:d6c9b09b4042 | 2 | * Copyright (c) 2006-2013 ARM Limited |
annieluo2 | 0:d6c9b09b4042 | 3 | * |
annieluo2 | 0:d6c9b09b4042 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
annieluo2 | 0:d6c9b09b4042 | 5 | * you may not use this file except in compliance with the License. |
annieluo2 | 0:d6c9b09b4042 | 6 | * You may obtain a copy of the License at |
annieluo2 | 0:d6c9b09b4042 | 7 | * |
annieluo2 | 0:d6c9b09b4042 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
annieluo2 | 0:d6c9b09b4042 | 9 | * |
annieluo2 | 0:d6c9b09b4042 | 10 | * Unless required by applicable law or agreed to in writing, software |
annieluo2 | 0:d6c9b09b4042 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
annieluo2 | 0:d6c9b09b4042 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
annieluo2 | 0:d6c9b09b4042 | 13 | * See the License for the specific language governing permissions and |
annieluo2 | 0:d6c9b09b4042 | 14 | * limitations under the License. |
annieluo2 | 0:d6c9b09b4042 | 15 | */ |
annieluo2 | 0:d6c9b09b4042 | 16 | #ifndef MBED_FILESYSTEMLIKE_H |
annieluo2 | 0:d6c9b09b4042 | 17 | #define MBED_FILESYSTEMLIKE_H |
annieluo2 | 0:d6c9b09b4042 | 18 | |
annieluo2 | 0:d6c9b09b4042 | 19 | #include "platform/platform.h" |
annieluo2 | 0:d6c9b09b4042 | 20 | |
annieluo2 | 0:d6c9b09b4042 | 21 | #include "drivers/FileBase.h" |
annieluo2 | 0:d6c9b09b4042 | 22 | #include "drivers/FileHandle.h" |
annieluo2 | 0:d6c9b09b4042 | 23 | #include "drivers/DirHandle.h" |
annieluo2 | 0:d6c9b09b4042 | 24 | |
annieluo2 | 0:d6c9b09b4042 | 25 | namespace mbed { |
annieluo2 | 0:d6c9b09b4042 | 26 | /** \addtogroup drivers */ |
annieluo2 | 0:d6c9b09b4042 | 27 | /** @{*/ |
annieluo2 | 0:d6c9b09b4042 | 28 | |
annieluo2 | 0:d6c9b09b4042 | 29 | /** A filesystem-like object is one that can be used to open files |
annieluo2 | 0:d6c9b09b4042 | 30 | * though it by fopen("/name/filename", mode) |
annieluo2 | 0:d6c9b09b4042 | 31 | * |
annieluo2 | 0:d6c9b09b4042 | 32 | * Implementations must define at least open (the default definitions |
annieluo2 | 0:d6c9b09b4042 | 33 | * of the rest of the functions just return error values). |
annieluo2 | 0:d6c9b09b4042 | 34 | * |
annieluo2 | 0:d6c9b09b4042 | 35 | * @Note Synchronization level: Set by subclass |
annieluo2 | 0:d6c9b09b4042 | 36 | */ |
annieluo2 | 0:d6c9b09b4042 | 37 | class FileSystemLike : public FileBase { |
annieluo2 | 0:d6c9b09b4042 | 38 | |
annieluo2 | 0:d6c9b09b4042 | 39 | public: |
annieluo2 | 0:d6c9b09b4042 | 40 | /** FileSystemLike constructor |
annieluo2 | 0:d6c9b09b4042 | 41 | * |
annieluo2 | 0:d6c9b09b4042 | 42 | * @param name The name to use for the filesystem. |
annieluo2 | 0:d6c9b09b4042 | 43 | */ |
annieluo2 | 0:d6c9b09b4042 | 44 | FileSystemLike(const char *name); |
annieluo2 | 0:d6c9b09b4042 | 45 | |
annieluo2 | 0:d6c9b09b4042 | 46 | virtual ~FileSystemLike(); |
annieluo2 | 0:d6c9b09b4042 | 47 | |
annieluo2 | 0:d6c9b09b4042 | 48 | static DirHandle *opendir(); |
annieluo2 | 0:d6c9b09b4042 | 49 | friend class BaseDirHandle; |
annieluo2 | 0:d6c9b09b4042 | 50 | |
annieluo2 | 0:d6c9b09b4042 | 51 | /** Opens a file from the filesystem |
annieluo2 | 0:d6c9b09b4042 | 52 | * |
annieluo2 | 0:d6c9b09b4042 | 53 | * @param filename The name of the file to open. |
annieluo2 | 0:d6c9b09b4042 | 54 | * @param flags One of O_RDONLY, O_WRONLY, or O_RDWR, OR'd with |
annieluo2 | 0:d6c9b09b4042 | 55 | * zero or more of O_CREAT, O_TRUNC, or O_APPEND. |
annieluo2 | 0:d6c9b09b4042 | 56 | * |
annieluo2 | 0:d6c9b09b4042 | 57 | * @returns |
annieluo2 | 0:d6c9b09b4042 | 58 | * A pointer to a FileHandle object representing the |
annieluo2 | 0:d6c9b09b4042 | 59 | * file on success, or NULL on failure. |
annieluo2 | 0:d6c9b09b4042 | 60 | */ |
annieluo2 | 0:d6c9b09b4042 | 61 | virtual FileHandle *open(const char *filename, int flags) = 0; |
annieluo2 | 0:d6c9b09b4042 | 62 | |
annieluo2 | 0:d6c9b09b4042 | 63 | /** Remove a file from the filesystem. |
annieluo2 | 0:d6c9b09b4042 | 64 | * |
annieluo2 | 0:d6c9b09b4042 | 65 | * @param filename the name of the file to remove. |
annieluo2 | 0:d6c9b09b4042 | 66 | * @param returns 0 on success, -1 on failure. |
annieluo2 | 0:d6c9b09b4042 | 67 | */ |
annieluo2 | 0:d6c9b09b4042 | 68 | virtual int remove(const char *filename) { (void) filename; return -1; }; |
annieluo2 | 0:d6c9b09b4042 | 69 | |
annieluo2 | 0:d6c9b09b4042 | 70 | /** Rename a file in the filesystem. |
annieluo2 | 0:d6c9b09b4042 | 71 | * |
annieluo2 | 0:d6c9b09b4042 | 72 | * @param oldname the name of the file to rename. |
annieluo2 | 0:d6c9b09b4042 | 73 | * @param newname the name to rename it to. |
annieluo2 | 0:d6c9b09b4042 | 74 | * |
annieluo2 | 0:d6c9b09b4042 | 75 | * @returns |
annieluo2 | 0:d6c9b09b4042 | 76 | * 0 on success, |
annieluo2 | 0:d6c9b09b4042 | 77 | * -1 on failure. |
annieluo2 | 0:d6c9b09b4042 | 78 | */ |
annieluo2 | 0:d6c9b09b4042 | 79 | virtual int rename(const char *oldname, const char *newname) { (void) oldname, (void) newname; return -1; }; |
annieluo2 | 0:d6c9b09b4042 | 80 | |
annieluo2 | 0:d6c9b09b4042 | 81 | /** Opens a directory in the filesystem and returns a DirHandle |
annieluo2 | 0:d6c9b09b4042 | 82 | * representing the directory stream. |
annieluo2 | 0:d6c9b09b4042 | 83 | * |
annieluo2 | 0:d6c9b09b4042 | 84 | * @param name The name of the directory to open. |
annieluo2 | 0:d6c9b09b4042 | 85 | * |
annieluo2 | 0:d6c9b09b4042 | 86 | * @returns |
annieluo2 | 0:d6c9b09b4042 | 87 | * A DirHandle representing the directory stream, or |
annieluo2 | 0:d6c9b09b4042 | 88 | * NULL on failure. |
annieluo2 | 0:d6c9b09b4042 | 89 | */ |
annieluo2 | 0:d6c9b09b4042 | 90 | virtual DirHandle *opendir(const char *name) { (void) name; return NULL; }; |
annieluo2 | 0:d6c9b09b4042 | 91 | |
annieluo2 | 0:d6c9b09b4042 | 92 | /** Creates a directory in the filesystem. |
annieluo2 | 0:d6c9b09b4042 | 93 | * |
annieluo2 | 0:d6c9b09b4042 | 94 | * @param name The name of the directory to create. |
annieluo2 | 0:d6c9b09b4042 | 95 | * @param mode The permissions to create the directory with. |
annieluo2 | 0:d6c9b09b4042 | 96 | * |
annieluo2 | 0:d6c9b09b4042 | 97 | * @returns |
annieluo2 | 0:d6c9b09b4042 | 98 | * 0 on success, |
annieluo2 | 0:d6c9b09b4042 | 99 | * -1 on failure. |
annieluo2 | 0:d6c9b09b4042 | 100 | */ |
annieluo2 | 0:d6c9b09b4042 | 101 | virtual int mkdir(const char *name, mode_t mode) { (void) name, (void) mode; return -1; } |
annieluo2 | 0:d6c9b09b4042 | 102 | |
annieluo2 | 0:d6c9b09b4042 | 103 | // TODO other filesystem functions (mkdir, rm, rn, ls etc) |
annieluo2 | 0:d6c9b09b4042 | 104 | }; |
annieluo2 | 0:d6c9b09b4042 | 105 | |
annieluo2 | 0:d6c9b09b4042 | 106 | } // namespace mbed |
annieluo2 | 0:d6c9b09b4042 | 107 | |
annieluo2 | 0:d6c9b09b4042 | 108 | #endif |
annieluo2 | 0:d6c9b09b4042 | 109 | |
annieluo2 | 0:d6c9b09b4042 | 110 | /** @}*/ |