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