Modified version of the official mbed-src lib. Provides some tiny but rather intrusive addons in the i2c-api.h for the mbed-RtosI2cDriver lib.
Fork of mbed-src by
cpp/DirHandle.h@2:143cac498751, 2013-02-18 (annotated)
- Committer:
- emilmont
- Date:
- Mon Feb 18 11:44:18 2013 +0000
- Revision:
- 2:143cac498751
- Parent:
- 0:fd0d7bdfcdc2
Update mbed sources to Rev 59
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 0:fd0d7bdfcdc2 | 1 | /* mbed Microcontroller Library |
emilmont | 2:143cac498751 | 2 | * Copyright (c) 2006-2013 ARM Limited |
mbed_official | 0:fd0d7bdfcdc2 | 3 | * |
emilmont | 2:143cac498751 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
emilmont | 2:143cac498751 | 5 | * you may not use this file except in compliance with the License. |
emilmont | 2:143cac498751 | 6 | * You may obtain a copy of the License at |
mbed_official | 0:fd0d7bdfcdc2 | 7 | * |
emilmont | 2:143cac498751 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
mbed_official | 0:fd0d7bdfcdc2 | 9 | * |
emilmont | 2:143cac498751 | 10 | * Unless required by applicable law or agreed to in writing, software |
emilmont | 2:143cac498751 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
emilmont | 2:143cac498751 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
emilmont | 2:143cac498751 | 13 | * See the License for the specific language governing permissions and |
emilmont | 2:143cac498751 | 14 | * limitations under the License. |
mbed_official | 0:fd0d7bdfcdc2 | 15 | */ |
mbed_official | 0:fd0d7bdfcdc2 | 16 | #ifndef MBED_DIRHANDLE_H |
mbed_official | 0:fd0d7bdfcdc2 | 17 | #define MBED_DIRHANDLE_H |
mbed_official | 0:fd0d7bdfcdc2 | 18 | |
emilmont | 2:143cac498751 | 19 | #if defined(__ARMCC_VERSION) || defined(__ICCARM__) |
emilmont | 2:143cac498751 | 20 | # define NAME_MAX 255 |
mbed_official | 0:fd0d7bdfcdc2 | 21 | typedef int mode_t; |
emilmont | 2:143cac498751 | 22 | |
mbed_official | 0:fd0d7bdfcdc2 | 23 | #else |
emilmont | 2:143cac498751 | 24 | # include <sys/syslimits.h> |
mbed_official | 0:fd0d7bdfcdc2 | 25 | #endif |
emilmont | 2:143cac498751 | 26 | |
mbed_official | 0:fd0d7bdfcdc2 | 27 | #include "FileHandle.h" |
mbed_official | 0:fd0d7bdfcdc2 | 28 | |
mbed_official | 0:fd0d7bdfcdc2 | 29 | struct dirent { |
mbed_official | 0:fd0d7bdfcdc2 | 30 | char d_name[NAME_MAX+1]; |
mbed_official | 0:fd0d7bdfcdc2 | 31 | }; |
mbed_official | 0:fd0d7bdfcdc2 | 32 | |
mbed_official | 0:fd0d7bdfcdc2 | 33 | namespace mbed { |
mbed_official | 0:fd0d7bdfcdc2 | 34 | |
mbed_official | 0:fd0d7bdfcdc2 | 35 | /** Represents a directory stream. Objects of this type are returned |
mbed_official | 0:fd0d7bdfcdc2 | 36 | * by a FileSystemLike's opendir method. Implementations must define |
mbed_official | 0:fd0d7bdfcdc2 | 37 | * at least closedir, readdir and rewinddir. |
mbed_official | 0:fd0d7bdfcdc2 | 38 | * |
mbed_official | 0:fd0d7bdfcdc2 | 39 | * If a FileSystemLike class defines the opendir method, then the |
emilmont | 2:143cac498751 | 40 | * directories of an object of that type can be accessed by |
mbed_official | 0:fd0d7bdfcdc2 | 41 | * DIR *d = opendir("/example/directory") (or opendir("/example") |
mbed_official | 0:fd0d7bdfcdc2 | 42 | * to open the root of the filesystem), and then using readdir(d) etc. |
mbed_official | 0:fd0d7bdfcdc2 | 43 | * |
mbed_official | 0:fd0d7bdfcdc2 | 44 | * The root directory is considered to contain all FileLike and |
mbed_official | 0:fd0d7bdfcdc2 | 45 | * FileSystemLike objects, so the DIR* returned by opendir("/") will |
mbed_official | 0:fd0d7bdfcdc2 | 46 | * reflect this. |
mbed_official | 0:fd0d7bdfcdc2 | 47 | */ |
mbed_official | 0:fd0d7bdfcdc2 | 48 | class DirHandle { |
mbed_official | 0:fd0d7bdfcdc2 | 49 | |
mbed_official | 0:fd0d7bdfcdc2 | 50 | public: |
mbed_official | 0:fd0d7bdfcdc2 | 51 | /** Closes the directory. |
mbed_official | 0:fd0d7bdfcdc2 | 52 | * |
mbed_official | 0:fd0d7bdfcdc2 | 53 | * @returns |
mbed_official | 0:fd0d7bdfcdc2 | 54 | * 0 on success, |
mbed_official | 0:fd0d7bdfcdc2 | 55 | * -1 on error. |
mbed_official | 0:fd0d7bdfcdc2 | 56 | */ |
mbed_official | 0:fd0d7bdfcdc2 | 57 | virtual int closedir()=0; |
emilmont | 2:143cac498751 | 58 | |
mbed_official | 0:fd0d7bdfcdc2 | 59 | /** Return the directory entry at the current position, and |
mbed_official | 0:fd0d7bdfcdc2 | 60 | * advances the position to the next entry. |
mbed_official | 0:fd0d7bdfcdc2 | 61 | * |
mbed_official | 0:fd0d7bdfcdc2 | 62 | * @returns |
mbed_official | 0:fd0d7bdfcdc2 | 63 | * A pointer to a dirent structure representing the |
mbed_official | 0:fd0d7bdfcdc2 | 64 | * directory entry at the current position, or NULL on reaching |
mbed_official | 0:fd0d7bdfcdc2 | 65 | * end of directory or error. |
mbed_official | 0:fd0d7bdfcdc2 | 66 | */ |
mbed_official | 0:fd0d7bdfcdc2 | 67 | virtual struct dirent *readdir()=0; |
mbed_official | 0:fd0d7bdfcdc2 | 68 | |
mbed_official | 0:fd0d7bdfcdc2 | 69 | /** Resets the position to the beginning of the directory. |
mbed_official | 0:fd0d7bdfcdc2 | 70 | */ |
mbed_official | 0:fd0d7bdfcdc2 | 71 | virtual void rewinddir()=0; |
mbed_official | 0:fd0d7bdfcdc2 | 72 | |
mbed_official | 0:fd0d7bdfcdc2 | 73 | /** Returns the current position of the DirHandle. |
mbed_official | 0:fd0d7bdfcdc2 | 74 | * |
mbed_official | 0:fd0d7bdfcdc2 | 75 | * @returns |
mbed_official | 0:fd0d7bdfcdc2 | 76 | * the current position, |
mbed_official | 0:fd0d7bdfcdc2 | 77 | * -1 on error. |
mbed_official | 0:fd0d7bdfcdc2 | 78 | */ |
mbed_official | 0:fd0d7bdfcdc2 | 79 | virtual off_t telldir() { return -1; } |
mbed_official | 0:fd0d7bdfcdc2 | 80 | |
mbed_official | 0:fd0d7bdfcdc2 | 81 | /** Sets the position of the DirHandle. |
mbed_official | 0:fd0d7bdfcdc2 | 82 | * |
mbed_official | 0:fd0d7bdfcdc2 | 83 | * @param location The location to seek to. Must be a value returned by telldir. |
mbed_official | 0:fd0d7bdfcdc2 | 84 | */ |
mbed_official | 0:fd0d7bdfcdc2 | 85 | virtual void seekdir(off_t location) { } |
emilmont | 2:143cac498751 | 86 | |
mbed_official | 0:fd0d7bdfcdc2 | 87 | virtual ~DirHandle() {} |
mbed_official | 0:fd0d7bdfcdc2 | 88 | }; |
mbed_official | 0:fd0d7bdfcdc2 | 89 | |
mbed_official | 0:fd0d7bdfcdc2 | 90 | } // namespace mbed |
mbed_official | 0:fd0d7bdfcdc2 | 91 | |
mbed_official | 0:fd0d7bdfcdc2 | 92 | typedef mbed::DirHandle DIR; |
mbed_official | 0:fd0d7bdfcdc2 | 93 | |
mbed_official | 0:fd0d7bdfcdc2 | 94 | extern "C" { |
mbed_official | 0:fd0d7bdfcdc2 | 95 | DIR *opendir(const char*); |
mbed_official | 0:fd0d7bdfcdc2 | 96 | struct dirent *readdir(DIR *); |
mbed_official | 0:fd0d7bdfcdc2 | 97 | int closedir(DIR*); |
mbed_official | 0:fd0d7bdfcdc2 | 98 | void rewinddir(DIR*); |
mbed_official | 0:fd0d7bdfcdc2 | 99 | long telldir(DIR*); |
mbed_official | 0:fd0d7bdfcdc2 | 100 | void seekdir(DIR*, long); |
mbed_official | 0:fd0d7bdfcdc2 | 101 | int mkdir(const char *name, mode_t n); |
mbed_official | 0:fd0d7bdfcdc2 | 102 | }; |
mbed_official | 0:fd0d7bdfcdc2 | 103 | |
mbed_official | 0:fd0d7bdfcdc2 | 104 | #endif /* MBED_DIRHANDLE_H */ |