Fork of mbed for KL05Z based smart sensor which has no crystal on the board, so MCG FEI mode is required.

Dependents:   smart-sensor-KL05Z-debug

Fork of mbed-src by Ermanno Brusadin

Committer:
ebrus
Date:
Wed Jul 27 18:35:32 2016 +0000
Revision:
0:0a673c671a56
4

Who changed what in which revision?

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