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