You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.8KB

  1. diff --git a/modules/juce_core/native/juce_posix_SharedCode.h b/modules/juce_core/native/juce_posix_SharedCode.h
  2. index 661f90d60..f3a8f061b 100644
  3. --- a/modules/juce_core/native/juce_posix_SharedCode.h
  4. +++ b/modules/juce_core/native/juce_posix_SharedCode.h
  5. @@ -611,12 +611,39 @@ File juce_getExecutableFile()
  6. auto localSymbol = (void*) juce_getExecutableFile;
  7. dladdr (localSymbol, &exeInfo);
  8. - return CharPointer_UTF8 (exeInfo.dli_fname);
  9. +
  10. + const CharPointer_UTF8 filename (exeInfo.dli_fname);
  11. +
  12. + // if the filename is absolute simply return it
  13. + if (File::isAbsolutePath (filename))
  14. + return filename;
  15. +
  16. + // if the filename is relative construct from CWD
  17. + if (filename[0] == '.')
  18. + return File::getCurrentWorkingDirectory().getChildFile (filename).getFullPathName();
  19. +
  20. + // filename is abstract, look up in PATH
  21. + if (const char* const envpath = ::getenv ("PATH"))
  22. + {
  23. + StringArray paths (StringArray::fromTokens (envpath, ":", ""));
  24. +
  25. + for (int i=paths.size(); --i>=0;)
  26. + {
  27. + const File filepath (File (paths[i]).getChildFile (filename));
  28. +
  29. + if (filepath.existsAsFile())
  30. + return filepath.getFullPathName();
  31. + }
  32. + }
  33. +
  34. + // if we reach this, we failed to find ourselves...
  35. + jassertfalse;
  36. + return filename;
  37. }
  38. };
  39. static String filename = DLAddrReader::getFilename();
  40. - return File::getCurrentWorkingDirectory().getChildFile (filename);
  41. + return filename;
  42. }
  43. //==============================================================================