|
Gaudi Framework, version v22r0 |
| Home | Generated: 9 Feb 2011 |
search for files in a list of directories More...
#include <DirSearchPath.h>

Classes | |
| class | eqPath |
| name More... | |
Public Types | |
| typedef boost::filesystem::path | path |
Public Member Functions | |
constructors | |
| DirSearchPath () | |
| DirSearchPath (const std::string &stringifiedPath, const char *separator=",:") | |
modifiers | |
| bool | add (const path &dir) |
| bool | addCWD () |
| add current work dir (*nix pwd) to path | |
accessors | |
| bool | find (const std::string &fileName, std::string &fullFileName) const |
| returns a flag if fileName found in search path, and sets ref to fully qualified file name (in native form) | |
| bool | find (const path &file, path &fileFound) const |
| returns a flag if file found in search path. Sets ref to completed path | |
| std::list< path > | find_all (const path &file) const |
| returns lists of files found in search path. | |
Static Public Member Functions | |
helpers | |
| static bool | existsDir (const std::string &dirName) |
| check dirName is valid | |
| static bool | existsDir (const path &dir) |
| check dir path is valid | |
Private Attributes | |
| std::list< path > | m_dirs |
| the dir container | |
search for files in a list of directories
Definition at line 19 of file DirSearchPath.h.
| typedef boost::filesystem::path DirSearchPath::path |
Definition at line 21 of file DirSearchPath.h.
| DirSearchPath::DirSearchPath | ( | ) | [inline] |
Definition at line 25 of file DirSearchPath.h.
00025 { addCWD(); }
| DirSearchPath::DirSearchPath | ( | const std::string & | stringifiedPath, | |
| const char * | separator = ",:" | |||
| ) |
| boost::filesystem::filesystem_error |
Definition at line 25 of file DirSearchPath.cpp.
00025 { 00026 addCWD(); //FIXME is this a good idea? 00027 00028 typedef tokenizer<char_separator<char> > Tokenizer; 00029 00030 Tokenizer tok(stringifiedPath, char_separator<char>(separator)); 00031 00032 00033 //add names to dir container, filtering dir names to remove invalid ones 00034 //notice how we iterate over all tokens even if there is an illegal one 00035 Tokenizer::iterator it = tok.begin(); 00036 while(it != tok.end()) { 00037 try { 00038 //path p( *(it++), boost::filesystem::native); 00039 // For some reason native() does not work with boost 1.31. Changed to no_check and cross the fingers.... 00040 path p( *(it++), boost::filesystem::no_check); 00041 add(p); 00042 } 00043 catch (boost::filesystem::filesystem_error /*err*/) { 00044 } 00045 } 00046 }
| bool DirSearchPath::add | ( | const path & | dir | ) |
| filesystem_error |
Definition at line 67 of file DirSearchPath.cpp.
| bool DirSearchPath::addCWD | ( | ) |
add current work dir (*nix pwd) to path
Definition at line 63 of file DirSearchPath.cpp.
00063 { 00064 return add(boost::filesystem::current_path()); 00065 }
| bool DirSearchPath::existsDir | ( | const path & | dir | ) | [static] |
check dir path is valid
Definition at line 122 of file DirSearchPath.cpp.
| bool DirSearchPath::existsDir | ( | const std::string & | dirName | ) | [static] |
check dirName is valid
Definition at line 115 of file DirSearchPath.cpp.
00115 { 00116 bool rc(false); 00117 try { 00118 rc=is_directory(path(dirName)); 00119 } catch(...) {} 00120 return rc; 00121 }
returns a flag if file found in search path. Sets ref to completed path
Definition at line 88 of file DirSearchPath.cpp.
| bool DirSearchPath::find | ( | const std::string & | fileName, | |
| std::string & | fullFileName | |||
| ) | const |
returns a flag if fileName found in search path, and sets ref to fully qualified file name (in native form)
Definition at line 77 of file DirSearchPath.cpp.
| std::list< DirSearchPath::path > DirSearchPath::find_all | ( | const path & | file | ) | const |
returns lists of files found in search path.
Definition at line 103 of file DirSearchPath.cpp.
00103 { 00104 std::list<path> found; 00105 for (std::list<path>::const_iterator iDir=m_dirs.begin(); iDir!=m_dirs.end(); ++iDir) { 00106 path full(*iDir / file); 00107 if (exists(full)) { 00108 found.push_back(full); 00109 } 00110 } 00111 return found; 00112 }
std::list<path> DirSearchPath::m_dirs [private] |
the dir container
Definition at line 81 of file DirSearchPath.h.