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.
DirHandle.h
00001 /* mbed Microcontroller Library 00002 * Copyright (c) 2006-2013 ARM Limited 00003 * 00004 * Permission is hereby granted, free of charge, to any person obtaining a copy 00005 * of this software and associated documentation files (the "Software"), to deal 00006 * in the Software without restriction, including without limitation the rights 00007 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00008 * copies of the Software, and to permit persons to whom the Software is 00009 * furnished to do so, subject to the following conditions: 00010 * 00011 * The above copyright notice and this permission notice shall be included in 00012 * all copies or substantial portions of the Software. 00013 * 00014 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00015 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00016 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00017 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00018 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00019 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 00020 * SOFTWARE. 00021 */ 00022 #ifndef MBED_DIRHANDLE_H 00023 #define MBED_DIRHANDLE_H 00024 00025 #if defined(__ARMCC_VERSION) || defined(__ICCARM__) 00026 # define NAME_MAX 255 00027 typedef int mode_t; 00028 00029 #else 00030 # include <sys/syslimits.h> 00031 #endif 00032 00033 #include "FileHandle.h" 00034 00035 struct dirent { 00036 char d_name[NAME_MAX+1]; 00037 }; 00038 00039 namespace mbed { 00040 00041 /** Represents a directory stream. Objects of this type are returned 00042 * by a FileSystemLike's opendir method. Implementations must define 00043 * at least closedir, readdir and rewinddir. 00044 * 00045 * If a FileSystemLike class defines the opendir method, then the 00046 * directories of an object of that type can be accessed by 00047 * DIR *d = opendir("/example/directory") (or opendir("/example") 00048 * to open the root of the filesystem), and then using readdir(d) etc. 00049 * 00050 * The root directory is considered to contain all FileLike and 00051 * FileSystemLike objects, so the DIR* returned by opendir("/") will 00052 * reflect this. 00053 */ 00054 class DirHandle { 00055 00056 public: 00057 /** Closes the directory. 00058 * 00059 * @returns 00060 * 0 on success, 00061 * -1 on error. 00062 */ 00063 virtual int closedir()=0; 00064 00065 /** Return the directory entry at the current position, and 00066 * advances the position to the next entry. 00067 * 00068 * @returns 00069 * A pointer to a dirent structure representing the 00070 * directory entry at the current position, or NULL on reaching 00071 * end of directory or error. 00072 */ 00073 virtual struct dirent *readdir()=0; 00074 00075 /** Resets the position to the beginning of the directory. 00076 */ 00077 virtual void rewinddir()=0; 00078 00079 /** Returns the current position of the DirHandle. 00080 * 00081 * @returns 00082 * the current position, 00083 * -1 on error. 00084 */ 00085 virtual off_t telldir() { return -1; } 00086 00087 /** Sets the position of the DirHandle. 00088 * 00089 * @param location The location to seek to. Must be a value returned by telldir. 00090 */ 00091 virtual void seekdir(off_t location) { } 00092 00093 virtual ~DirHandle() {} 00094 }; 00095 00096 } // namespace mbed 00097 00098 typedef mbed::DirHandle DIR; 00099 00100 extern "C" { 00101 DIR *opendir(const char*); 00102 struct dirent *readdir(DIR *); 00103 int closedir(DIR*); 00104 void rewinddir(DIR*); 00105 long telldir(DIR*); 00106 void seekdir(DIR*, long); 00107 int mkdir(const char *name, mode_t n); 00108 }; 00109 00110 #endif /* MBED_DIRHANDLE_H */ 00111
Generated on Wed Jul 13 2022 02:59:11 by
