00001
00002 #include "PathDriver.h"
00003
00004 #include <sys/types.h>
00005 #include <sys/stat.h>
00006 #include <dirent.h>
00007 #include <unistd.h>
00008
00009
00010 SOME::PathDriver::PathDriver()
00011 {
00012 delimit="/";
00013 }
00014
00015 void SOME::PathDriver::checkPath( std::string path, bool &isDir, bool &isFile )
00016 {
00017 struct stat buf;
00018
00019 if(stat(path.c_str(), &buf)==0)
00020 {
00021 isDir = ((buf.st_mode & __S_IFDIR) == __S_IFDIR);
00022 isFile = ((buf.st_mode & __S_IFDIR) != __S_IFDIR);
00023 }
00024 else
00025 {
00026 isFile = isDir = false;
00027 }
00028 }
00029
00030 void SOME::PathDriver::enumDirectory(std::string path, std::list<std::string> &file_list)
00031 {
00032 DIR *dir=opendir( path.c_str() );
00033
00034 dirent *de=readdir(dir);
00035
00036 while( de!=NULL )
00037 {
00038
00039 string file_path = path + delimit + string(de->d_name);
00040
00041
00042 DIR *dcheck = opendir(file_path.c_str());
00043 if(dcheck==NULL)
00044 file_list.push_back( file_path );
00045 else
00046 closedir( dcheck );
00047
00048 de=readdir( dir );
00049 }
00050
00051 closedir( dir );
00052
00053
00054 }
00055
00056 std::string SOME::PathDriver::getDelimit()
00057 {
00058 return delimit;
00059 }
00060