00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 00011 00012 00013 00014 00015 00016 00017 00018 00019
00020
00021 #include "Path.h"
00022 #include "PathDriver.h"
00023 #include "some_algo.h"
00024
00025 SOME::Path::iterator SOME::Path::begin()
00026 {
00027 return file_list.begin();
00028 }
00029 SOME::Path::iterator SOME::Path::end()
00030 {
00031 return file_list.end();
00032 }
00033 SOME::Path::size_type SOME::Path::size()
00034 {
00035 return file_list.size();
00036 }
00037
00038 SOME::Path::Path()
00039 {
00040 delimit=pdriver.getDelimit();
00041 }
00042
00043 SOME::Path::Path( std::string path )
00044 {
00045 delimit=pdriver.getDelimit();
00046 set(path);
00047 }
00048
00049 SOME::Path::Path( const char * path )
00050 {
00051 delimit=pdriver.getDelimit();
00052 set(string(path));
00053 }
00054
00055 bool SOME::Path::isFile()
00056 {
00057 return isfile;
00058 }
00059
00060 bool SOME::Path::isDir()
00061 {
00062 return isdir;
00063 }
00064
00065 void SOME::Path::operator=( std::string path )
00066 {
00067 set(path);
00068 }
00069
00070 void SOME::Path::operator=( const char * path )
00071 {
00072 set(string(path));
00073 }
00074
00075 void SOME::Path::set( std::string path )
00076 {
00077 xppath=path;
00078
00079 ppath = parsePath( path );
00080
00081 pdriver.checkPath( ppath, isdir, isfile );
00082
00083 if(isfile)
00084 {
00085 file_list.push_back( ppath );
00086 }
00087 else if(isdir)
00088 {
00089
00090
00091 }
00092
00093
00094 else
00095 {
00096
00097 std::string::size_type i = path.rfind(delimit);
00098 if(i==std::string::npos)
00099 {
00100 pdriver.enumDirectory( "", file_list );
00101 regex_remove(file_list.begin(), file_list.end(), file_list, path);
00102 }
00103 else
00104 {
00105 pdriver.enumDirectory( path.substr(0, i),file_list );
00106 regex_remove(file_list.begin(), file_list.end(), file_list, path.substr(i+1));
00107 }
00108 }
00109
00110 }
00111
00112 std::string SOME::Path::parsePath( std::string path )
00113 {
00114 if(delimit!="/")
00115 while (int pos = path.find(delimit,0)!=std::string::npos)
00116 path.replace(pos, 1, delimit);
00117
00118
00119 return path;
00120 }