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.cpp
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 #include "mbed.h" 00012 #include "DirectoryList.h" 00013 #include <algorithm> 00014 00015 DirectoryList::DirectoryList( char *path ) : error_flag( NOT_INITIALIZED ) 00016 { 00017 init( string( path ) ); 00018 } 00019 00020 DirectoryList::DirectoryList( std::string path ) : error_flag( NOT_INITIALIZED ) 00021 { 00022 init( path ); 00023 } 00024 00025 void DirectoryList::init( std::string path ) 00026 { 00027 DIR *dir; 00028 struct dirent *dp; 00029 00030 if ( NULL == (dir = opendir( path.c_str() )) ) { 00031 error_flag = ERROR_AT_FILE_OPEN; 00032 return; 00033 } 00034 00035 while ( NULL != (dp = readdir( dir )) ) 00036 this->push_back( dp->d_name ); 00037 00038 closedir( dir ); 00039 00040 std::sort( this->begin(), this->end() ); 00041 error_flag = NO_ERROR; 00042 } 00043 00044 DirectoryList::~DirectoryList() 00045 { 00046 } 00047 00048 int DirectoryList::error_check( void ) 00049 { 00050 return error_flag; 00051 }
Generated on Tue Jul 12 2022 20:39:56 by 1.7.2