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