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