10 std::string
searchDirs(
const std::vector<std::string>& dirs,
const std::string& filename ) {
11 for (
unsigned int i=0; i<dirs.size(); i++ ) {
12 std::string path = dirs[i] +
'/' + filename;
19 PRINT_DEBUG1(
"FileManager: %s not found.\n", filename.c_str() );
29 static char* stgPath = getenv(
"STAGEPATH");
30 if ( stgPath == NULL )
33 return std::string( stgPath );
38 PRINT_DEBUG1(
"FileManager: trying %s\n", filename.c_str());
42 static std::vector<std::string> paths;
43 static bool ranOnce =
false;
47 std::string SharePath = INSTALL_PREFIX
"/share/stage";
48 paths.push_back( SharePath );
52 std::istringstream is( stgPath );
54 while ( getline( is, path,
':' ) ) {
55 paths.push_back( path );
56 PRINT_DEBUG1(
"FileManager - INIT: added path %s\n", path.c_str() );
61 PRINT_DEBUG1(
"FileManager - INIT: %d paths in search paths\n", paths.size() );
70 iFile.open( path.c_str() );
71 if ( iFile.is_open() ) {
81 std::string pathChars(
"\\/" );
82 std::string::size_type loc = path.find_last_of( pathChars );
83 if ( loc == std::string::npos )
86 return path.substr( 0, loc );
static bool readable(const std::string &path)
Determine whether a file can be opened for reading.
The Stage library uses its own namespace.
std::string searchDirs(const std::vector< std::string > &dirs, const std::string &filename)
static std::string stagePath()
Return the STAGEPATH environment variable.
std::string stripFilename(const std::string &path)
static std::string findFile(const std::string &filename)
#define PRINT_DEBUG1(m, a)