diff --git a/src/converter/mtsimport.cpp b/src/converter/mtsimport.cpp index 7fa466f1..af0d4ce1 100644 --- a/src/converter/mtsimport.cpp +++ b/src/converter/mtsimport.cpp @@ -174,14 +174,6 @@ int ubi_main(int argc, char **argv) { FileResolver *fileResolver = Thread::getThread()->getFileResolver(); -#if defined(__LINUX__) - fileResolver->addPath(MTS_RESOURCE_DIR); -#elif defined(__OSX__) - MTS_AUTORELEASE_BEGIN() - fileResolver->addPath(__ubi_bundlepath()); - MTS_AUTORELEASE_END() -#endif - #if !defined(WIN32) /* Correct number parsing on some locales (e.g. ru_RU) */ setlocale(LC_NUMERIC, "C"); diff --git a/src/libcore/fresolver.cpp b/src/libcore/fresolver.cpp index f535cbb7..59fcf252 100644 --- a/src/libcore/fresolver.cpp +++ b/src/libcore/fresolver.cpp @@ -4,6 +4,25 @@ MTS_NAMESPACE_BEGIN FileResolver::FileResolver() { m_paths.push_back(fs::current_path()); +#if defined(__LINUX__) + char exePath[PATH_MAX]; + memset(exePath, 0, PATH_MAX); + if (readlink("/proc/self/exe", exePath, PATH_MAX) != -1) + addPath(fs::path(exePath).parent_path()); + else + Log(EError, "Could not detect the executable path!"); + addPath(MTS_RESOURCE_DIR); +#elif defined(__OSX__) + MTS_AUTORELEASE_BEGIN() + Thread::getThread()->getFileResolver()->addPath(__ubi_bundlepath()); + MTS_AUTORELEASE_END() +#elif defined(WIN32) + char lpFilename[1024]; + if (GetModuleFileNameA(NULL, lpFilename, sizeof(lpFilename))) + addPath(fs::path(lpFilename).parent_path()); + else + Log(EError, "Could not detect the executable path!"); +#endif } FileResolver *FileResolver::clone() const { diff --git a/src/mitsuba/mitsuba.cpp b/src/mitsuba/mitsuba.cpp index f51f8768..ebb9c442 100644 --- a/src/mitsuba/mitsuba.cpp +++ b/src/mitsuba/mitsuba.cpp @@ -267,6 +267,7 @@ int ubi_main(int argc, char **argv) { /* Prepare for parsing scene descriptions */ SAXParser* parser = new SAXParser(); + cout << fileResolver->toString() << endl; fs::path schemaPath = fileResolver->resolveAbsolute("schema/scene.xsd"); /* Check against the 'scene.xsd' XML Schema */ @@ -358,16 +359,6 @@ int main(int argc, char **argv) { SLog(EError, "Could not find the required version of winsock.dll!"); #endif -#ifdef __LINUX__ - Thread::getThread()->getFileResolver()->addPath(MTS_RESOURCE_DIR); -#endif - -#if defined(__OSX__) - MTS_AUTORELEASE_BEGIN() - Thread::getThread()->getFileResolver()->addPath(__ubi_bundlepath()); - MTS_AUTORELEASE_END() -#endif - #if !defined(WIN32) /* Correct number parsing on some locales (e.g. ru_RU) */ setlocale(LC_NUMERIC, "C"); diff --git a/src/mitsuba/mtssrv.cpp b/src/mitsuba/mtssrv.cpp index 39758f19..d731869f 100644 --- a/src/mitsuba/mtssrv.cpp +++ b/src/mitsuba/mtssrv.cpp @@ -394,17 +394,6 @@ int main(int argc, char **argv) { SLog(EError, "Could not find the required version of winsock.dll!"); #endif -#ifdef __LINUX__ - Thread::getThread()->getFileResolver()->addPath(MTS_RESOURCE_DIR); -#endif - -#if defined(__OSX__) - MTS_AUTORELEASE_BEGIN() - Thread::getThread()->getFileResolver()->addPath(__ubi_bundlepath()); - MTS_AUTORELEASE_END() -#endif - - #if !defined(WIN32) setlocale(LC_NUMERIC, "C"); #endif diff --git a/src/mitsuba/mtsutil.cpp b/src/mitsuba/mtsutil.cpp index 14e9daee..38459de9 100644 --- a/src/mitsuba/mtsutil.cpp +++ b/src/mitsuba/mtsutil.cpp @@ -373,16 +373,6 @@ int main(int argc, char **argv) { SLog(EError, "Could not find the required version of winsock.dll!"); #endif -#ifdef __LINUX__ - Thread::getThread()->getFileResolver()->addPath(MTS_RESOURCE_DIR); -#endif - -#if defined(__OSX__) - MTS_AUTORELEASE_BEGIN() - Thread::getThread()->getFileResolver()->addPath(__ubi_bundlepath()); - MTS_AUTORELEASE_END() -#endif - #if !defined(WIN32) /* Correct number parsing on some locales (e.g. ru_RU) */ setlocale(LC_NUMERIC, "C"); diff --git a/src/qtgui/main.cpp b/src/qtgui/main.cpp index 8e6331b3..b2557ba3 100644 --- a/src/qtgui/main.cpp +++ b/src/qtgui/main.cpp @@ -109,12 +109,10 @@ int main(int argc, char *argv[]) { #if defined(__LINUX__) XInitThreads(); - Thread::getThread()->getFileResolver()->addPath(MTS_RESOURCE_DIR); #endif #if defined(__OSX__) MTS_AUTORELEASE_BEGIN() - Thread::getThread()->getFileResolver()->addPath(__ubi_bundlepath()); /* Required for the mouse relocation in GLWidget */ CGSetLocalEventsSuppressionInterval(0.0f); MTS_AUTORELEASE_END()