DefaultFileFinder.cpp

Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 
00006 #include "cafe/DefaultFileFinder.hpp"
00007 
00008 #include "TSystem.h"
00009 
00010 namespace cafe {
00011     
00014     DefaultFileFinder::DefaultFileFinder()
00015     {
00016         push_back("./");
00017         if(const char *priv = getenv("SRT_PRIVATE_CONTEXT")) {
00018             push_back(priv);
00019         }
00020         if(const char *pub = getenv("SRT_PUBLIC_CONTEXT")) {
00021             push_back(pub);
00022         }
00023     }
00024     
00026     void DefaultFileFinder::push_back (const std::string& location)
00027     {
00028         _locations.push_back(location);
00029     }
00030 
00032     void DefaultFileFinder::push_front (const std::string& location)
00033     {
00034         _locations.push_front(location);
00035     }
00036     
00039     std::string DefaultFileFinder::findFile (const std::string& base_name) const
00040     {
00041         using namespace std;
00042 
00043         // return absolute path names unchanged
00044         if(!base_name.empty() && base_name[0] == '/') return base_name;
00045 
00046         for(list<string>::const_iterator it = _locations.begin();
00047             it != _locations.end();
00048             ++it) {
00049             string path = (*it) + '/' + base_name;
00050             if(gSystem->AccessPathName(path.c_str(), kReadPermission) == 0) {
00051                 return path;
00052             }
00053         }
00054 
00055         return "";
00056     }
00057    
00058 }

Generated on Thu Apr 3 04:14:22 2008 for CAF by doxygen 1.3.4