mbed library sources. Supersedes mbed-src.

Dependents:   Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more

Committer:
<>
Date:
Tue Dec 20 17:27:56 2016 +0000
Revision:
153:fa9ff456f731
Parent:
149:156823d33999
Child:
160:d5399cc887bb
This updates the lib to the mbed lib v132

Who changed what in which revision?

UserRevisionLine numberNew contents of line
<> 149:156823d33999 1 /* mbed Microcontroller Library
<> 149:156823d33999 2 * Copyright (c) 2006-2013 ARM Limited
<> 149:156823d33999 3 *
<> 149:156823d33999 4 * Licensed under the Apache License, Version 2.0 (the "License");
<> 149:156823d33999 5 * you may not use this file except in compliance with the License.
<> 149:156823d33999 6 * You may obtain a copy of the License at
<> 149:156823d33999 7 *
<> 149:156823d33999 8 * http://www.apache.org/licenses/LICENSE-2.0
<> 149:156823d33999 9 *
<> 149:156823d33999 10 * Unless required by applicable law or agreed to in writing, software
<> 149:156823d33999 11 * distributed under the License is distributed on an "AS IS" BASIS,
<> 149:156823d33999 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<> 149:156823d33999 13 * See the License for the specific language governing permissions and
<> 149:156823d33999 14 * limitations under the License.
<> 149:156823d33999 15 */
<> 149:156823d33999 16 #ifndef MBED_DIRHANDLE_H
<> 149:156823d33999 17 #define MBED_DIRHANDLE_H
<> 149:156823d33999 18
<> 149:156823d33999 19 #if defined(__ARMCC_VERSION) || defined(__ICCARM__)
<> 149:156823d33999 20 # define NAME_MAX 255
<> 149:156823d33999 21 typedef int mode_t;
<> 149:156823d33999 22
<> 149:156823d33999 23 #else
<> 149:156823d33999 24 # include <sys/syslimits.h>
<> 149:156823d33999 25 #endif
<> 149:156823d33999 26
<> 149:156823d33999 27 #include "FileHandle.h"
<> 149:156823d33999 28
<> 149:156823d33999 29 struct dirent {
<> 149:156823d33999 30 char d_name[NAME_MAX+1];
<> 149:156823d33999 31 };
<> 149:156823d33999 32
<> 149:156823d33999 33 namespace mbed {
<> 149:156823d33999 34 /** \addtogroup drivers */
<> 149:156823d33999 35 /** @{*/
<> 149:156823d33999 36
<> 149:156823d33999 37 /** Represents a directory stream. Objects of this type are returned
<> 149:156823d33999 38 * by a FileSystemLike's opendir method. Implementations must define
<> 149:156823d33999 39 * at least closedir, readdir and rewinddir.
<> 149:156823d33999 40 *
<> 149:156823d33999 41 * If a FileSystemLike class defines the opendir method, then the
<> 149:156823d33999 42 * directories of an object of that type can be accessed by
<> 149:156823d33999 43 * DIR *d = opendir("/example/directory") (or opendir("/example")
<> 149:156823d33999 44 * to open the root of the filesystem), and then using readdir(d) etc.
<> 149:156823d33999 45 *
<> 149:156823d33999 46 * The root directory is considered to contain all FileLike and
<> 149:156823d33999 47 * FileSystemLike objects, so the DIR* returned by opendir("/") will
<> 149:156823d33999 48 * reflect this.
<> 149:156823d33999 49 *
<> 149:156823d33999 50 * @Note Synchronization level: Set by subclass
<> 149:156823d33999 51 */
<> 149:156823d33999 52 class DirHandle {
<> 149:156823d33999 53
<> 149:156823d33999 54 public:
<> 149:156823d33999 55 /** Closes the directory.
<> 149:156823d33999 56 *
<> 149:156823d33999 57 * @returns
<> 149:156823d33999 58 * 0 on success,
<> 149:156823d33999 59 * -1 on error.
<> 149:156823d33999 60 */
<> 149:156823d33999 61 virtual int closedir()=0;
<> 149:156823d33999 62
<> 149:156823d33999 63 /** Return the directory entry at the current position, and
<> 149:156823d33999 64 * advances the position to the next entry.
<> 149:156823d33999 65 *
<> 149:156823d33999 66 * @returns
<> 149:156823d33999 67 * A pointer to a dirent structure representing the
<> 149:156823d33999 68 * directory entry at the current position, or NULL on reaching
<> 149:156823d33999 69 * end of directory or error.
<> 149:156823d33999 70 */
<> 149:156823d33999 71 virtual struct dirent *readdir()=0;
<> 149:156823d33999 72
<> 149:156823d33999 73 /** Resets the position to the beginning of the directory.
<> 149:156823d33999 74 */
<> 149:156823d33999 75 virtual void rewinddir()=0;
<> 149:156823d33999 76
<> 149:156823d33999 77 /** Returns the current position of the DirHandle.
<> 149:156823d33999 78 *
<> 149:156823d33999 79 * @returns
<> 149:156823d33999 80 * the current position,
<> 149:156823d33999 81 * -1 on error.
<> 149:156823d33999 82 */
<> 149:156823d33999 83 virtual off_t telldir() { return -1; }
<> 149:156823d33999 84
<> 149:156823d33999 85 /** Sets the position of the DirHandle.
<> 149:156823d33999 86 *
<> 149:156823d33999 87 * @param location The location to seek to. Must be a value returned by telldir.
<> 149:156823d33999 88 */
<> 149:156823d33999 89 virtual void seekdir(off_t location) { (void)location;}
<> 149:156823d33999 90
<> 149:156823d33999 91 virtual ~DirHandle() {}
<> 149:156823d33999 92
<> 149:156823d33999 93 protected:
<> 149:156823d33999 94
<> 149:156823d33999 95 /** Acquire exclusive access to this object.
<> 149:156823d33999 96 */
<> 149:156823d33999 97 virtual void lock() {
<> 149:156823d33999 98 // Stub
<> 149:156823d33999 99 }
<> 149:156823d33999 100
<> 149:156823d33999 101 /** Release exclusive access to this object.
<> 149:156823d33999 102 */
<> 149:156823d33999 103 virtual void unlock() {
<> 149:156823d33999 104 // Stub
<> 149:156823d33999 105 }
<> 149:156823d33999 106 };
<> 149:156823d33999 107
<> 149:156823d33999 108 } // namespace mbed
<> 149:156823d33999 109
<> 149:156823d33999 110 typedef mbed::DirHandle DIR;
<> 149:156823d33999 111
<> 149:156823d33999 112 extern "C" {
<> 149:156823d33999 113 DIR *opendir(const char*);
<> 149:156823d33999 114 struct dirent *readdir(DIR *);
<> 149:156823d33999 115 int closedir(DIR*);
<> 149:156823d33999 116 void rewinddir(DIR*);
<> 149:156823d33999 117 long telldir(DIR*);
<> 149:156823d33999 118 void seekdir(DIR*, long);
<> 149:156823d33999 119 int mkdir(const char *name, mode_t n);
<> 149:156823d33999 120 };
<> 149:156823d33999 121
<> 149:156823d33999 122 #endif /* MBED_DIRHANDLE_H */
<> 149:156823d33999 123
<> 149:156823d33999 124 /** @}*/