IOTIO

Dependencies:   Nucleo_BLE_API_IOTIO Nucleo_BLE_BlueNRG Nucleo_BLE_DemoApp Nucleo_Sensor_Shield mbed

Dependents:   Nucleo_BLE_Demo_IOTIO

Fork of Nucleo_BLE_Demo by Cortex Challenge Team

Committer:
16038618
Date:
Sat Oct 29 15:11:28 2016 +0000
Revision:
1:4bdfa7d7e8bf
IOTIO

Who changed what in which revision?

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