mbed-os for GR-LYCHEE

Dependents:   mbed-os-example-blinky-gr-lychee GR-Boads_Camera_sample GR-Boards_Audio_Recoder GR-Boads_Camera_DisplayApp ... more

Committer:
dkato
Date:
Fri Feb 02 05:42:23 2018 +0000
Revision:
0:f782d9c66c49
mbed-os for GR-LYCHEE

Who changed what in which revision?

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