X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2Fmoof%2Fresource.cc;h=053fc0b31849e9b37991d90f671e71ee7983800d;hp=314f80b5db81707e73b4cb3d91300f6d5b5a8ea0;hb=382626aad0a683ed8642a6a807eea743db45f7f8;hpb=1da520638918096276158ecdfaeebc14a3d70be7 diff --git a/src/moof/resource.cc b/src/moof/resource.cc index 314f80b..053fc0b 100644 --- a/src/moof/resource.cc +++ b/src/moof/resource.cc @@ -127,7 +127,7 @@ resource_ptr resource::load(const std::string& path) { std::string extension = stlplus::extension_part(path); - std::string path1 = find_file(path); + std::string path1 = path; if (!find(path1)) { log_error("trying to load missing resource:", path1); @@ -212,21 +212,35 @@ void resource::add_search_paths(const std::string& paths) bool resource::find(const std::string& path) { - std::string file = stlplus::lookup(path, search_paths_, ":"); - log_info("found file", file, "in", search_paths_); - return !stlplus::lookup(path, search_paths_, ":").empty(); + //std::string file = stlplus::lookup(path, search_paths_, ":"); + //log_info("found file", file, "in", search_paths_); + //return !stlplus::lookup(path, search_paths_, ":").empty(); + return find_file(path) != ""; } std::string resource::find_file(const std::string& name) { - log_info("looking for", name, "in", search_paths_); - return stlplus::lookup(name, search_paths_, ":"); + //log_info("looking for", name, "in", search_paths_); + //return stlplus::lookup(name, search_paths_, ":"); + + std::vector paths; + boost::split(paths, search_paths_, boost::is_any_of(":")); + + std::vector::iterator it; + for (it = paths.begin(); it != paths.end(); ++it) + { + *it += "/"; + *it += name; + log_info("looking for", name, "in", *it); + if (stlplus::file_exists(*it)) return *it; + } + + return std::string(); } FILE* resource::open_file(const std::string& path, const std::string& mode) { - std::string file = stlplus::lookup(path, search_paths_, ":"); - return fopen(file.c_str(), mode.c_str()); + return fopen(find_file(path).c_str(), mode.c_str()); }