diff --git a/code/FileSystemFilter.h b/code/FileSystemFilter.h index 2504e8566..707a94b61 100644 --- a/code/FileSystemFilter.h +++ b/code/FileSystemFilter.h @@ -172,7 +172,7 @@ private: void BuildPath (std::string& in) const { // if we can already access the file, great. - if (in.length() < 3 || wrapped->Exists(in.c_str())) { + if (in.length() < 3 || wrapped->Exists(in)) { return; } @@ -180,8 +180,25 @@ private: if (in[1] != ':') { // append base path and try - in = base + in; - if (wrapped->Exists(in.c_str())) { + const std::string tmp = base + in; + if (wrapped->Exists(tmp)) { + in = tmp; + return; + } + } + + // Chop of the file name and look in the current directory + size_t pos = in.rfind("/"); + if (std::string::npos == pos) { + pos = in.rfind("\\"); + } + + if (std::string::npos != pos) { + std::string tmp = "."; + tmp += wrapped->getOsSeparator(); + tmp += in.substr(pos+1, in.length()-pos); + if (wrapped->Exists(tmp)) { + in = tmp; return; } } diff --git a/code/LWSLoader.cpp b/code/LWSLoader.cpp index 6519805e8..54a15d0f9 100644 --- a/code/LWSLoader.cpp +++ b/code/LWSLoader.cpp @@ -452,8 +452,9 @@ std::string LWSImporter::FindLWOFile(const std::string& in) } else tmp = in; - if (io->Exists(tmp)) + if (io->Exists(tmp)) { return in; + } // file is not accessible for us ... maybe it's packed by // LightWave's 'Package Scene' command? @@ -468,8 +469,10 @@ std::string LWSImporter::FindLWOFile(const std::string& in) return test; test = ".." + io->getOsSeparator() + test; - if (io->Exists(test)) + if (io->Exists(test)) { return test; + } + // return original path, maybe the IOsystem knows better return tmp;