Main Page   Class Hierarchy   Compound List   File List   Compound Members  

PathDriver.cpp

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         //cout<<file_path<<endl;
00041         //check if it is a directory
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 

Generated at Fri Dec 8 14:24:48 2000 for SOMELib by doxygen1.2.1 written by Dimitri van Heesch, © 1997-2000