Nicer hgignore, forgotten fresolver.cpp file

metadata
Wenzel Jakob 2010-09-12 11:48:34 +02:00
parent 8e7fdb48dc
commit 9ac6d2c145
2 changed files with 106 additions and 18 deletions

View File

@ -1,46 +1,62 @@
^Mitsuba.app/.*$
.*\.obj$
.*\.os$
.*\.so$
.*\.pyc$
.*\.o$
.*\.exe$
.*\.pdb$
.*\.manifest$
.*\.exp$
.*\.dylib$
# Documentation
^doc/doxygen/.*$
^doc/.*\.aux$
^doc/.*\.log$
^doc/.*\.out$
^doc/.*\.pdf$
^doc/.*\.toc$
# Qt-related
.*ui_.*\.h$
.*moc_.*\.cc$
.*qrc_.*\.cc$
\.DS_Store
# SCons-related
^\.sconf_temp/.*$
^.sconsign.dblite$
^config.py$
^config.log$
^.sconsign.dblite$
^src/utils/addimages$
.*\.pyc$
# OSX binaries and byproducts
^Mitsuba.app/.*$
\.DS_Store
.*\.dylib$
# Linux binaries and byproducts
^src/utils/createvol$
^src/utils/dumpimage$
^src/utils/joinrgb$
^src/utils/ssalbedo$
^src/utils/ttest$
^src/utils/utils_test$
^dist/.*$
^mitsuba$
^mtssrv$
^mtsgui$
^mtsimport$
^mtsutil$
.*\.so$
.*\.os$
.*\.o$
# Windows binaries and byproducts
.*\.exe$
.*\.obj$
^src/.*\.lib$
^src/.*\.dll$
^plugins/.*\.lib$
^plugins/.*\.dll$
^dist/.*$
tools/windows/mitsuba_res.res
.*\.pdb$
.*\.manifest$
.*\.exp$
# Imported geometry
^meshes/.*$
^textures/.*$
^mitsuba.*.log$
^doc/doxygen/.*$
# Eclipse CDT project files
^.externalToolBuilders/.*$
^.settings/.*$
^.cproject$

72
src/libcore/fresolver.cpp Normal file
View File

@ -0,0 +1,72 @@
#include <mitsuba/core/fresolver.h>
MTS_NAMESPACE_BEGIN
FileResolver::FileResolver() {
m_paths.push_back(fs::current_path());
}
FileResolver *FileResolver::clone() const {
FileResolver *cloned = new FileResolver();
cloned->m_paths = m_paths;
return cloned;
}
void FileResolver::clear() {
m_paths.clear();
}
void FileResolver::addPath(const fs::path &path) {
bool found = false;
for (size_t i=0; i<m_paths.size(); ++i) {
if (m_paths[i] == path) {
found = true;
break;
}
}
if (!found)
m_paths.push_back(path);
}
fs::path FileResolver::resolve(const fs::path &path) const {
if (!fs::exists(path)) {
for (unsigned int i=0; i<m_paths.size(); i++) {
fs::path newPath = m_paths[i] / path;
if (fs::exists(newPath))
return newPath;
}
}
return path;
}
std::vector<fs::path> FileResolver::resolveAll(const fs::path &path) const {
std::vector<fs::path> results;
if (fs::exists(path))
results.push_back(path);
for (unsigned int i=0; i<m_paths.size(); i++) {
fs::path newPath = m_paths[i] / path;
if (fs::exists(newPath))
results.push_back(path);
}
return results;
}
fs::path FileResolver::resolveAbsolute(const fs::path &path) const {
return fs::complete(resolve(path));
}
std::string FileResolver::toString() const {
std::ostringstream oss;
oss << "FileResolver[" << endl
<< " paths = {" << endl;
for (size_t i=0; i<m_paths.size(); ++i)
oss << " \"" << m_paths[i].file_string() << "\"," << endl;
oss << " }" << endl
<< "]";
return oss.str();
}
MTS_IMPLEMENT_CLASS(FileResolver, false, Object)
MTS_NAMESPACE_END