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