Mark Turner
/
lightsense_kl46z_basic_v2
Tried to initialize the buttons and slider but couldn't get it to work.
mbed/DirHandle.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_DIRHANDLE_H |
mturner5 | 0:0d6b77c9ae01 | 17 | #define MBED_DIRHANDLE_H |
mturner5 | 0:0d6b77c9ae01 | 18 | |
mturner5 | 0:0d6b77c9ae01 | 19 | #if defined(__ARMCC_VERSION) || defined(__ICCARM__) |
mturner5 | 0:0d6b77c9ae01 | 20 | # define NAME_MAX 255 |
mturner5 | 0:0d6b77c9ae01 | 21 | typedef int mode_t; |
mturner5 | 0:0d6b77c9ae01 | 22 | |
mturner5 | 0:0d6b77c9ae01 | 23 | #else |
mturner5 | 0:0d6b77c9ae01 | 24 | # include <sys/syslimits.h> |
mturner5 | 0:0d6b77c9ae01 | 25 | #endif |
mturner5 | 0:0d6b77c9ae01 | 26 | |
mturner5 | 0:0d6b77c9ae01 | 27 | #include "FileHandle.h" |
mturner5 | 0:0d6b77c9ae01 | 28 | |
mturner5 | 0:0d6b77c9ae01 | 29 | struct dirent { |
mturner5 | 0:0d6b77c9ae01 | 30 | char d_name[NAME_MAX+1]; |
mturner5 | 0:0d6b77c9ae01 | 31 | }; |
mturner5 | 0:0d6b77c9ae01 | 32 | |
mturner5 | 0:0d6b77c9ae01 | 33 | namespace mbed { |
mturner5 | 0:0d6b77c9ae01 | 34 | |
mturner5 | 0:0d6b77c9ae01 | 35 | /** Represents a directory stream. Objects of this type are returned |
mturner5 | 0:0d6b77c9ae01 | 36 | * by a FileSystemLike's opendir method. Implementations must define |
mturner5 | 0:0d6b77c9ae01 | 37 | * at least closedir, readdir and rewinddir. |
mturner5 | 0:0d6b77c9ae01 | 38 | * |
mturner5 | 0:0d6b77c9ae01 | 39 | * If a FileSystemLike class defines the opendir method, then the |
mturner5 | 0:0d6b77c9ae01 | 40 | * directories of an object of that type can be accessed by |
mturner5 | 0:0d6b77c9ae01 | 41 | * DIR *d = opendir("/example/directory") (or opendir("/example") |
mturner5 | 0:0d6b77c9ae01 | 42 | * to open the root of the filesystem), and then using readdir(d) etc. |
mturner5 | 0:0d6b77c9ae01 | 43 | * |
mturner5 | 0:0d6b77c9ae01 | 44 | * The root directory is considered to contain all FileLike and |
mturner5 | 0:0d6b77c9ae01 | 45 | * FileSystemLike objects, so the DIR* returned by opendir("/") will |
mturner5 | 0:0d6b77c9ae01 | 46 | * reflect this. |
mturner5 | 0:0d6b77c9ae01 | 47 | */ |
mturner5 | 0:0d6b77c9ae01 | 48 | class DirHandle { |
mturner5 | 0:0d6b77c9ae01 | 49 | |
mturner5 | 0:0d6b77c9ae01 | 50 | public: |
mturner5 | 0:0d6b77c9ae01 | 51 | /** Closes the directory. |
mturner5 | 0:0d6b77c9ae01 | 52 | * |
mturner5 | 0:0d6b77c9ae01 | 53 | * @returns |
mturner5 | 0:0d6b77c9ae01 | 54 | * 0 on success, |
mturner5 | 0:0d6b77c9ae01 | 55 | * -1 on error. |
mturner5 | 0:0d6b77c9ae01 | 56 | */ |
mturner5 | 0:0d6b77c9ae01 | 57 | virtual int closedir()=0; |
mturner5 | 0:0d6b77c9ae01 | 58 | |
mturner5 | 0:0d6b77c9ae01 | 59 | /** Return the directory entry at the current position, and |
mturner5 | 0:0d6b77c9ae01 | 60 | * advances the position to the next entry. |
mturner5 | 0:0d6b77c9ae01 | 61 | * |
mturner5 | 0:0d6b77c9ae01 | 62 | * @returns |
mturner5 | 0:0d6b77c9ae01 | 63 | * A pointer to a dirent structure representing the |
mturner5 | 0:0d6b77c9ae01 | 64 | * directory entry at the current position, or NULL on reaching |
mturner5 | 0:0d6b77c9ae01 | 65 | * end of directory or error. |
mturner5 | 0:0d6b77c9ae01 | 66 | */ |
mturner5 | 0:0d6b77c9ae01 | 67 | virtual struct dirent *readdir()=0; |
mturner5 | 0:0d6b77c9ae01 | 68 | |
mturner5 | 0:0d6b77c9ae01 | 69 | /** Resets the position to the beginning of the directory. |
mturner5 | 0:0d6b77c9ae01 | 70 | */ |
mturner5 | 0:0d6b77c9ae01 | 71 | virtual void rewinddir()=0; |
mturner5 | 0:0d6b77c9ae01 | 72 | |
mturner5 | 0:0d6b77c9ae01 | 73 | /** Returns the current position of the DirHandle. |
mturner5 | 0:0d6b77c9ae01 | 74 | * |
mturner5 | 0:0d6b77c9ae01 | 75 | * @returns |
mturner5 | 0:0d6b77c9ae01 | 76 | * the current position, |
mturner5 | 0:0d6b77c9ae01 | 77 | * -1 on error. |
mturner5 | 0:0d6b77c9ae01 | 78 | */ |
mturner5 | 0:0d6b77c9ae01 | 79 | virtual off_t telldir() { return -1; } |
mturner5 | 0:0d6b77c9ae01 | 80 | |
mturner5 | 0:0d6b77c9ae01 | 81 | /** Sets the position of the DirHandle. |
mturner5 | 0:0d6b77c9ae01 | 82 | * |
mturner5 | 0:0d6b77c9ae01 | 83 | * @param location The location to seek to. Must be a value returned by telldir. |
mturner5 | 0:0d6b77c9ae01 | 84 | */ |
mturner5 | 0:0d6b77c9ae01 | 85 | virtual void seekdir(off_t location) { } |
mturner5 | 0:0d6b77c9ae01 | 86 | |
mturner5 | 0:0d6b77c9ae01 | 87 | virtual ~DirHandle() {} |
mturner5 | 0:0d6b77c9ae01 | 88 | }; |
mturner5 | 0:0d6b77c9ae01 | 89 | |
mturner5 | 0:0d6b77c9ae01 | 90 | } // namespace mbed |
mturner5 | 0:0d6b77c9ae01 | 91 | |
mturner5 | 0:0d6b77c9ae01 | 92 | typedef mbed::DirHandle DIR; |
mturner5 | 0:0d6b77c9ae01 | 93 | |
mturner5 | 0:0d6b77c9ae01 | 94 | extern "C" { |
mturner5 | 0:0d6b77c9ae01 | 95 | DIR *opendir(const char*); |
mturner5 | 0:0d6b77c9ae01 | 96 | struct dirent *readdir(DIR *); |
mturner5 | 0:0d6b77c9ae01 | 97 | int closedir(DIR*); |
mturner5 | 0:0d6b77c9ae01 | 98 | void rewinddir(DIR*); |
mturner5 | 0:0d6b77c9ae01 | 99 | long telldir(DIR*); |
mturner5 | 0:0d6b77c9ae01 | 100 | void seekdir(DIR*, long); |
mturner5 | 0:0d6b77c9ae01 | 101 | int mkdir(const char *name, mode_t n); |
mturner5 | 0:0d6b77c9ae01 | 102 | }; |
mturner5 | 0:0d6b77c9ae01 | 103 | |
mturner5 | 0:0d6b77c9ae01 | 104 | #endif /* MBED_DIRHANDLE_H */ |