]> Dogcows Code - chaz/yoink/blobdiff - src/moof/resource.cc
the massive refactoring effort
[chaz/yoink] / src / moof / resource.cc
similarity index 69%
rename from src/Moof/Resource.cc
rename to src/moof/resource.cc
index d1dc5fac425d1f3f808eb66357b44706a5d4f3a0..3512878bb039f5cede9b164940c744eccadd664f 100644 (file)
 
 #include <boost/algorithm/string.hpp>
 
-#include "Log.hh"
-#include "Resource.hh"
+#include "log.hh"
+#include "resource.hh"
 
 
-namespace Mf {
+namespace moof {
 
 
 // static member
-std::vector<std::string> Resource::gSearchPaths;
+std::vector<std::string> resource::search_paths_;
 
 
-void Resource::addSearchPaths(const std::string& paths)
+void resource::add_search_paths(const std::string& paths)
 {
        std::vector<std::string> pathList;
        boost::split(pathList, paths, boost::is_any_of(":"));
 
-       addSearchPaths(pathList);
+       add_search_paths(pathList);
 }
 
-void Resource::addSearchPaths(const std::vector<std::string>& pathList)
+void resource::add_search_paths(const std::vector<std::string>& pathList)
 {
        std::vector<std::string>::const_iterator it;
        for (it = pathList.begin(); it != pathList.end(); ++it)
@@ -46,27 +46,17 @@ void Resource::addSearchPaths(const std::vector<std::string>& 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<std::string> preList;
+       boost::split(preList, temp_prefix, boost::is_any_of(":"));
+#else
        std::vector<std::string> preList;
        boost::split(preList, prefix, boost::is_any_of(":"));
+#endif
+
        std::vector<std::string> postList;
        boost::split(postList, extension, boost::is_any_of(":"));
 
        std::vector<std::string>::iterator it;
-       for (it = gSearchPaths.begin(); it != gSearchPaths.end(); ++it)
+       for (it = search_paths_.begin(); it != search_paths_.end(); ++it)
        {
                std::vector<std::string>::iterator jt;
                for (jt = preList.begin(); jt != preList.end(); ++jt)
@@ -133,5 +127,5 @@ FILE* Resource::openFile(std::string& path,
 }
 
 
-} // namespace Mf
+} // namespace moof
 
This page took 0.022207 seconds and 4 git commands to generate.