#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)
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);
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)
}
-} // namespace Mf
+} // namespace moof