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) 2015 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
dkato 0:f782d9c66c49 17 #ifndef DIR_H
dkato 0:f782d9c66c49 18 #define DIR_H
dkato 0:f782d9c66c49 19
dkato 0:f782d9c66c49 20 #include "filesystem/FileSystem.h"
dkato 0:f782d9c66c49 21
dkato 0:f782d9c66c49 22 namespace mbed {
dkato 0:f782d9c66c49 23 /** \addtogroup filesystem */
dkato 0:f782d9c66c49 24 /** @{*/
dkato 0:f782d9c66c49 25
dkato 0:f782d9c66c49 26
dkato 0:f782d9c66c49 27 /** Dir class
dkato 0:f782d9c66c49 28 */
dkato 0:f782d9c66c49 29 class Dir {
dkato 0:f782d9c66c49 30 public:
dkato 0:f782d9c66c49 31 /** Create an uninitialized directory
dkato 0:f782d9c66c49 32 *
dkato 0:f782d9c66c49 33 * Must call open to initialize the directory on a file system
dkato 0:f782d9c66c49 34 */
dkato 0:f782d9c66c49 35 Dir();
dkato 0:f782d9c66c49 36
dkato 0:f782d9c66c49 37 /** Open a directory on a filesystem
dkato 0:f782d9c66c49 38 *
dkato 0:f782d9c66c49 39 * @param fs Filesystem as target for a directory
dkato 0:f782d9c66c49 40 * @param path Name of the directory to open
dkato 0:f782d9c66c49 41 */
dkato 0:f782d9c66c49 42 Dir(FileSystem *fs, const char *path);
dkato 0:f782d9c66c49 43
dkato 0:f782d9c66c49 44 /** Destroy a file
dkato 0:f782d9c66c49 45 *
dkato 0:f782d9c66c49 46 * Closes file if the file is still open
dkato 0:f782d9c66c49 47 */
dkato 0:f782d9c66c49 48 virtual ~Dir();
dkato 0:f782d9c66c49 49
dkato 0:f782d9c66c49 50 /** Open a directory on the filesystem
dkato 0:f782d9c66c49 51 *
dkato 0:f782d9c66c49 52 * @param fs Filesystem as target for a directory
dkato 0:f782d9c66c49 53 * @param path Name of the directory to open
dkato 0:f782d9c66c49 54 * @return 0 on success, negative error code on failure
dkato 0:f782d9c66c49 55 */
dkato 0:f782d9c66c49 56 virtual int open(FileSystem *fs, const char *path);
dkato 0:f782d9c66c49 57
dkato 0:f782d9c66c49 58 /** Close a directory
dkato 0:f782d9c66c49 59 *
dkato 0:f782d9c66c49 60 * return 0 on success, negative error code on failure
dkato 0:f782d9c66c49 61 */
dkato 0:f782d9c66c49 62 virtual int close();
dkato 0:f782d9c66c49 63
dkato 0:f782d9c66c49 64 /** Read the next directory entry
dkato 0:f782d9c66c49 65 *
dkato 0:f782d9c66c49 66 * @param path The buffer to read the null terminated path name in to
dkato 0:f782d9c66c49 67 * @param ent The directory entry to fill out
dkato 0:f782d9c66c49 68 * @return 1 on reading a filename, 0 at end of directory, negative error on failure
dkato 0:f782d9c66c49 69 */
dkato 0:f782d9c66c49 70 virtual ssize_t read(struct dirent *ent);
dkato 0:f782d9c66c49 71
dkato 0:f782d9c66c49 72 /** Set the current position of the directory
dkato 0:f782d9c66c49 73 *
dkato 0:f782d9c66c49 74 * @param offset Offset of the location to seek to,
dkato 0:f782d9c66c49 75 * must be a value returned from tell
dkato 0:f782d9c66c49 76 */
dkato 0:f782d9c66c49 77 virtual void seek(off_t offset);
dkato 0:f782d9c66c49 78
dkato 0:f782d9c66c49 79 /** Get the current position of the directory
dkato 0:f782d9c66c49 80 *
dkato 0:f782d9c66c49 81 * @return Position of the directory that can be passed to rewind
dkato 0:f782d9c66c49 82 */
dkato 0:f782d9c66c49 83 virtual off_t tell();
dkato 0:f782d9c66c49 84
dkato 0:f782d9c66c49 85 /** Rewind the current position to the beginning of the directory
dkato 0:f782d9c66c49 86 */
dkato 0:f782d9c66c49 87 virtual void rewind();
dkato 0:f782d9c66c49 88
dkato 0:f782d9c66c49 89 /** Get the sizeof the directory
dkato 0:f782d9c66c49 90 *
dkato 0:f782d9c66c49 91 * @return Number of files in the directory
dkato 0:f782d9c66c49 92 */
dkato 0:f782d9c66c49 93 virtual size_t size();
dkato 0:f782d9c66c49 94
dkato 0:f782d9c66c49 95 private:
dkato 0:f782d9c66c49 96 FileSystem *_fs;
dkato 0:f782d9c66c49 97 fs_dir_t _dir;
dkato 0:f782d9c66c49 98 };
dkato 0:f782d9c66c49 99
dkato 0:f782d9c66c49 100
dkato 0:f782d9c66c49 101 /** @}*/
dkato 0:f782d9c66c49 102 } // namespace mbed
dkato 0:f782d9c66c49 103
dkato 0:f782d9c66c49 104 #endif