help :(

Dependencies:   FFT

Committer:
dimitryjl23
Date:
Fri Dec 04 18:01:22 2020 +0000
Revision:
11:951bbb0385aa
Parent:
0:d6c9b09b4042
Final :)

Who changed what in which revision?

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