Directry file listing class Instance will be a vector of string class which holds the file name of given path.
Dependents: ika_shouyu_poppoyaki DirectoryList_Hello ika_shouyu_poppoyaki eVY1_SMF_player ... more
DirectoryList.h
00001 /** 00002 * DirectoryList library 00003 * 00004 * @author Tedd OKANO 00005 * @version 0.1 00006 * @date Jan-2015 00007 * 00008 * A simple directory listing interface 00009 */ 00010 00011 #ifndef MBED_DIRECTORY_LIST_H 00012 #define MBED_DIRECTORY_LIST_H 00013 00014 #include <vector> 00015 #include <string> 00016 #include "DirHandle.h" 00017 00018 /** DirectoryList class 00019 * 00020 * Simple interface to get file name list of directory 00021 * which is specified by path. 00022 * 00023 * The DirectoryList instance will be an object of "std::vector<std::string>". 00024 * 00025 * This library works on local strage on mbed as well as on USB strage. 00026 * (It has not been tested on SD yet.) 00027 * 00028 * Example: 00029 * @code 00030 * #include "mbed.h" 00031 * #include "DirectoryList.h" 00032 * 00033 * LocalFileSystem local( "local" ); 00034 * 00035 * int main(void) 00036 * { 00037 * DirectoryList dir( "/local" ); 00038 * 00039 * if ( dir.error_check() ) 00040 * error( "directory could not be opened\r\n" ); 00041 * 00042 * for ( int i = 0; i < dir.size(); i++ ) 00043 * printf( "%s\r\n", dir[ i ].c_str() ); 00044 * } 00045 * @endcode 00046 */ 00047 00048 class DirectoryList : public std::vector<std::string> 00049 { 00050 typedef enum { 00051 NO_ERROR = 0, 00052 NOT_INITIALIZED, 00053 ERROR_AT_FILE_OPEN 00054 } ErrorCode; 00055 00056 public: 00057 00058 /** Create a DirectoryList instance of specified path 00059 * 00060 * @param path string which tells directory path 00061 */ 00062 DirectoryList( char *path ); 00063 00064 /** Create a DirectoryList instance of specified path 00065 * 00066 * @param path string which tells directory path 00067 */ 00068 DirectoryList( std::string path ); 00069 00070 /** Destructor of DirectoryList 00071 */ 00072 ~DirectoryList(); 00073 00074 /** Error check function 00075 * 00076 * @return zero if no error 00077 */ 00078 int error_check( void ); 00079 00080 private: 00081 00082 void init( std::string path ); 00083 int error_flag; 00084 }; 00085 00086 #endif // MBED_DIRECTORY_LIST_H
Generated on Tue Jul 12 2022 20:39:56 by 1.7.2