This is a repository for all my programs or modified programs.

Committer:
mturner5
Date:
Sun Sep 11 23:48:09 2016 +0000
Revision:
0:72480818e4a9
Made delays for the LEDS and button presses

Who changed what in which revision?

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