X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2Fmoof%2Fresource.cc;fp=src%2FMoof%2FResource.cc;h=3512878bb039f5cede9b164940c744eccadd664f;hp=d1dc5fac425d1f3f808eb66357b44706a5d4f3a0;hb=831f04d4bc19a390415ac0bbac4331c7a65509bc;hpb=299af4f2047e767e5d79501c26444473bda64c64 diff --git a/src/Moof/Resource.cc b/src/moof/resource.cc similarity index 69% rename from src/Moof/Resource.cc rename to src/moof/resource.cc index d1dc5fa..3512878 100644 --- a/src/Moof/Resource.cc +++ b/src/moof/resource.cc @@ -11,26 +11,26 @@ #include -#include "Log.hh" -#include "Resource.hh" +#include "log.hh" +#include "resource.hh" -namespace Mf { +namespace moof { // static member -std::vector Resource::gSearchPaths; +std::vector resource::search_paths_; -void Resource::addSearchPaths(const std::string& paths) +void resource::add_search_paths(const std::string& paths) { std::vector pathList; boost::split(pathList, paths, boost::is_any_of(":")); - addSearchPaths(pathList); + add_search_paths(pathList); } -void Resource::addSearchPaths(const std::vector& pathList) +void resource::add_search_paths(const std::vector& pathList) { std::vector::const_iterator it; for (it = pathList.begin(); it != pathList.end(); ++it) @@ -46,27 +46,17 @@ void Resource::addSearchPaths(const std::vector& pathList) boost::replace_all(path, "/", "\\"); #endif - gSearchPaths.push_back(path); - logInfo << "added search path " << path << std::endl; + search_paths_.push_back(path); + log_info << "added search path " << path << std::endl; } } -std::string Resource::getPath(const std::string& path, - const std::string& prefix, - const std::string& extension) -{ - std::string realPath(path); - if (getPath(realPath, prefix, extension)) return realPath; - - return std::string(); -} - -bool Resource::getPath(std::string& path, +bool resource::find_path(std::string& path, const std::string& prefix, const std::string& extension) { - FILE* file = openFile(path, prefix, extension); + FILE* file = open_file(path, prefix, extension); if (file) { fclose(file); @@ -76,24 +66,28 @@ bool Resource::getPath(std::string& path, return false; } -FILE* Resource::openFile(std::string& path, - std::string prefix, +FILE* resource::open_file(std::string& path, + const std::string& prefix, const std::string& extension, const std::string& mode) { #if defined(_WIN32) - // Windows always has to be the odd one. + // windows always has to be a little different boost::replace_all(path, "/", "\\"); - boost::replace_all(prefix, "/", "\\"); -#endif - + std::string temp_prefix(prefix); + boost::replace_all(temp_prefix, "/", "\\"); + std::vector preList; + boost::split(preList, temp_prefix, boost::is_any_of(":")); +#else std::vector preList; boost::split(preList, prefix, boost::is_any_of(":")); +#endif + std::vector postList; boost::split(postList, extension, boost::is_any_of(":")); std::vector::iterator it; - for (it = gSearchPaths.begin(); it != gSearchPaths.end(); ++it) + for (it = search_paths_.begin(); it != search_paths_.end(); ++it) { std::vector::iterator jt; for (jt = preList.begin(); jt != preList.end(); ++jt) @@ -133,5 +127,5 @@ FILE* Resource::openFile(std::string& path, } -} // namespace Mf +} // namespace moof