nicer default path setup
parent
f74e40f8cc
commit
98b98ddcf0
|
@ -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");
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue