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/.*$ # Documentation
.*\.obj$ ^doc/doxygen/.*$
.*\.os$
.*\.so$
.*\.pyc$
.*\.o$
.*\.exe$
.*\.pdb$
.*\.manifest$
.*\.exp$
.*\.dylib$
^doc/.*\.aux$ ^doc/.*\.aux$
^doc/.*\.log$ ^doc/.*\.log$
^doc/.*\.out$ ^doc/.*\.out$
^doc/.*\.pdf$ ^doc/.*\.pdf$
^doc/.*\.toc$ ^doc/.*\.toc$
# Qt-related
.*ui_.*\.h$ .*ui_.*\.h$
.*moc_.*\.cc$ .*moc_.*\.cc$
.*qrc_.*\.cc$ .*qrc_.*\.cc$
\.DS_Store
# SCons-related
^\.sconf_temp/.*$ ^\.sconf_temp/.*$
^.sconsign.dblite$
^config.py$ ^config.py$
^config.log$ ^config.log$
^.sconsign.dblite$ .*\.pyc$
^src/utils/addimages$
# OSX binaries and byproducts
^Mitsuba.app/.*$
\.DS_Store
.*\.dylib$
# Linux binaries and byproducts
^src/utils/createvol$ ^src/utils/createvol$
^src/utils/dumpimage$ ^src/utils/dumpimage$
^src/utils/joinrgb$ ^src/utils/joinrgb$
^src/utils/ssalbedo$
^src/utils/ttest$ ^src/utils/ttest$
^src/utils/utils_test$
^dist/.*$
^mitsuba$ ^mitsuba$
^mtssrv$ ^mtssrv$
^mtsgui$ ^mtsgui$
^mtsimport$ ^mtsimport$
^mtsutil$ ^mtsutil$
.*\.so$
.*\.os$
.*\.o$
# Windows binaries and byproducts
.*\.exe$
.*\.obj$
^src/.*\.lib$ ^src/.*\.lib$
^src/.*\.dll$ ^src/.*\.dll$
^plugins/.*\.lib$ ^plugins/.*\.lib$
^plugins/.*\.dll$ ^plugins/.*\.dll$
^dist/.*$
tools/windows/mitsuba_res.res tools/windows/mitsuba_res.res
.*\.pdb$
.*\.manifest$
.*\.exp$
# Imported geometry
^meshes/.*$ ^meshes/.*$
^textures/.*$ ^textures/.*$
^mitsuba.*.log$ ^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