Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: mbed-os-example-blinky-gr-lychee GR-Boads_Camera_sample GR-Boards_Audio_Recoder GR-Boads_Camera_DisplayApp ... more
Dir.h
00001 /* mbed Microcontroller Library 00002 * Copyright (c) 2015 ARM Limited 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 #ifndef DIR_H 00018 #define DIR_H 00019 00020 #include "filesystem/FileSystem.h" 00021 00022 namespace mbed { 00023 /** \addtogroup filesystem */ 00024 /** @{*/ 00025 00026 00027 /** Dir class 00028 */ 00029 class Dir { 00030 public: 00031 /** Create an uninitialized directory 00032 * 00033 * Must call open to initialize the directory on a file system 00034 */ 00035 Dir(); 00036 00037 /** Open a directory on a filesystem 00038 * 00039 * @param fs Filesystem as target for a directory 00040 * @param path Name of the directory to open 00041 */ 00042 Dir(FileSystem *fs, const char *path); 00043 00044 /** Destroy a file 00045 * 00046 * Closes file if the file is still open 00047 */ 00048 virtual ~Dir(); 00049 00050 /** Open a directory on the filesystem 00051 * 00052 * @param fs Filesystem as target for a directory 00053 * @param path Name of the directory to open 00054 * @return 0 on success, negative error code on failure 00055 */ 00056 virtual int open(FileSystem *fs, const char *path); 00057 00058 /** Close a directory 00059 * 00060 * return 0 on success, negative error code on failure 00061 */ 00062 virtual int close(); 00063 00064 /** Read the next directory entry 00065 * 00066 * @param path The buffer to read the null terminated path name in to 00067 * @param ent The directory entry to fill out 00068 * @return 1 on reading a filename, 0 at end of directory, negative error on failure 00069 */ 00070 virtual ssize_t read(struct dirent *ent); 00071 00072 /** Set the current position of the directory 00073 * 00074 * @param offset Offset of the location to seek to, 00075 * must be a value returned from tell 00076 */ 00077 virtual void seek(off_t offset); 00078 00079 /** Get the current position of the directory 00080 * 00081 * @return Position of the directory that can be passed to rewind 00082 */ 00083 virtual off_t tell(); 00084 00085 /** Rewind the current position to the beginning of the directory 00086 */ 00087 virtual void rewind(); 00088 00089 /** Get the sizeof the directory 00090 * 00091 * @return Number of files in the directory 00092 */ 00093 virtual size_t size(); 00094 00095 private: 00096 FileSystem *_fs; 00097 fs_dir_t _dir; 00098 }; 00099 00100 00101 /** @}*/ 00102 } // namespace mbed 00103 00104 #endif
Generated on Tue Jul 12 2022 11:02:23 by
1.7.2