Created
April 15, 2015 09:12
-
-
Save falkTX/0af036871c13389d64e3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/modules/juce_core/native/juce_posix_SharedCode.h b/modules/juce_core/native/juce_posix_SharedCode.h | |
index c94d3a6..dd47d98 100644 | |
--- a/modules/juce_core/native/juce_posix_SharedCode.h | |
+++ b/modules/juce_core/native/juce_posix_SharedCode.h | |
@@ -596,12 +596,38 @@ File juce_getExecutableFile() | |
{ | |
Dl_info exeInfo; | |
dladdr ((void*) juce_getExecutableFile, &exeInfo); | |
- return CharPointer_UTF8 (exeInfo.dli_fname); | |
+ const CharPointer_UTF8 filename (exeInfo.dli_fname); | |
+ | |
+ // if the filename is absolute simply return it | |
+ if (File::isAbsolutePath (filename)) | |
+ return filename; | |
+ | |
+ // if the filename is relative construct from CWD | |
+ if (filename[0] == '.') | |
+ return File::getCurrentWorkingDirectory().getChildFile (filename).getFullPathName(); | |
+ | |
+ // filename is abstract, look up in PATH | |
+ if (const char* const envpath = ::getenv ("PATH")) | |
+ { | |
+ StringArray paths (StringArray::fromTokens (envpath, ":", "")); | |
+ | |
+ for (int i = 0; i < paths.size(); ++i) | |
+ { | |
+ const File filepath (File (paths[i]).getChildFile (filename)); | |
+ | |
+ if (filepath.existsAsFile()) | |
+ return filepath.getFullPathName(); | |
+ } | |
+ } | |
+ | |
+ // if we reach this, we failed to find ourselves... | |
+ jassertfalse; | |
+ return filename; | |
} | |
}; | |
static String filename (DLAddrReader::getFilename()); | |
- return File::getCurrentWorkingDirectory().getChildFile (filename); | |
+ return filename; | |
#endif | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment