dhgdh

Dependencies:   MAX44000 PWM_Tone_Library nexpaq_mdk

Fork of LED_Demo by joey shelton

Committer:
cyberjoey
Date:
Sat Oct 22 01:31:58 2016 +0000
Revision:
9:6bb35cef007d
Parent:
1:55a6170b404f
WORKING

Who changed what in which revision?

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