resolve files case-insensitively on Linux if a case-sensitive search did not succeed (to handle Mitsuba scenes that work perfectly fine on Windows/OSX)
parent
83f0109f84
commit
f1f91c2ebd
|
@ -85,11 +85,32 @@ void FileResolver::appendPath(const fs::path &path) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fs::path FileResolver::resolve(const fs::path &path) const {
|
fs::path FileResolver::resolve(const fs::path &path) const {
|
||||||
|
/* First, try to resolve in case-sensitive mode */
|
||||||
for (size_t i=0; i<m_paths.size(); i++) {
|
for (size_t i=0; i<m_paths.size(); i++) {
|
||||||
fs::path newPath = m_paths[i] / path;
|
fs::path newPath = m_paths[i] / path;
|
||||||
if (fs::exists(newPath))
|
if (fs::exists(newPath))
|
||||||
return newPath;
|
return newPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(__LINUX__)
|
||||||
|
/* On Linux, also try case-insensitive mode if the above failed */
|
||||||
|
fs::path parentPath = path.parent_path();
|
||||||
|
std::string filename = boost::to_lower_copy(path.filename().string());
|
||||||
|
|
||||||
|
for (size_t i=0; i<m_paths.size(); i++) {
|
||||||
|
fs::path path = m_paths[i] / parentPath;
|
||||||
|
|
||||||
|
if (!fs::is_directory(path))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
fs::directory_iterator end, it(path);
|
||||||
|
for (; it != end; ++it) {
|
||||||
|
if (boost::algorithm::to_lower_copy(it->path().filename().string()) == filename)
|
||||||
|
return it->path();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue