|
- diff --git a/modules/juce_core/native/juce_posix_SharedCode.h b/modules/juce_core/native/juce_posix_SharedCode.h
- index 661f90d60..f3a8f061b 100644
- --- a/modules/juce_core/native/juce_posix_SharedCode.h
- +++ b/modules/juce_core/native/juce_posix_SharedCode.h
- @@ -611,12 +611,39 @@ File juce_getExecutableFile()
-
- auto localSymbol = (void*) juce_getExecutableFile;
- dladdr (localSymbol, &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=paths.size(); --i>=0;)
- + {
- + 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;
- }
-
- //==============================================================================
|