SPKT

Dependencies:   F746_GUI SD_PlayerSkeleton F746_SAI_IO

Committer:
phungductung
Date:
Tue Jun 04 21:37:21 2019 +0000
Revision:
0:8ede47d38d10
SPKT

Who changed what in which revision?

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