Browse Source

Added a File::invokedExecutableFile key that can be used to find the name of the file or link that launched the exe

tags/2021-05-28
Julian Storer 15 years ago
parent
commit
1b0e85d187
5 changed files with 33 additions and 0 deletions
  1. +8
    -0
      src/application/juce_Application.cpp
  2. +10
    -0
      src/io/files/juce_File.h
  3. +7
    -0
      src/native/linux/juce_linux_Files.cpp
  4. +7
    -0
      src/native/mac/juce_mac_Files.mm
  5. +1
    -0
      src/native/windows/juce_win32_Files.cpp

+ 8
- 0
src/application/juce_Application.cpp View File

@@ -273,9 +273,17 @@ int JUCEApplication::shutdownAppAndClearUp()
extern int juce_IPhoneMain (int argc, char* argv[], JUCEApplication* app);
#endif
#if ! JUCE_WINDOWS
extern const char* juce_Argv0;
#endif
int JUCEApplication::main (int argc, char* argv[],
JUCEApplication* const newApp)
{
#if ! JUCE_WINDOWS
juce_Argv0 = argv[0];
#endif
#if JUCE_IPHONE
const ScopedAutoReleasePool pool;
return juce_IPhoneMain (argc, argv, newApp);


+ 10
- 0
src/io/files/juce_File.h View File

@@ -779,6 +779,9 @@ public:
On the mac this will return the unix binary, not the package folder - see
currentApplicationFile for that.
See also invokedExecutableFile, which is similar, but if the exe was launched from a
file link, invokedExecutableFile will return the name of the link.
*/
currentExecutableFile,
@@ -792,6 +795,13 @@ public:
*/
currentApplicationFile,
/** Returns the file that was invoked to launch this executable.
This may differ from currentExecutableFile if the app was started from e.g. a link - this
will return the name of the link that was used, whereas currentExecutableFile will return
the actual location of the target executable.
*/
invokedExecutableFile,
/** The directory in which applications normally get installed.
So on windows, this would be something like "c:\program files", on the


+ 7
- 0
src/native/linux/juce_linux_Files.cpp View File

@@ -171,6 +171,8 @@ bool File::isHidden() const throw()
}
//==============================================================================
const char* juce_Argv0 = 0; // referenced from juce_Application.cpp
const File File::getSpecialLocation (const SpecialLocationType type)
{
switch (type)
@@ -219,6 +221,11 @@ const File File::getSpecialLocation (const SpecialLocationType type)
return tmp;
}
case invokedExecutableFile:
if (juce_Argv0 != 0)
return File (String::fromUTF8 ((const uint8*) juce_Argv0));
// deliberate fall-through...
case currentExecutableFile:
case currentApplicationFile:
return juce_getExecutableFile();


+ 7
- 0
src/native/mac/juce_mac_Files.mm View File

@@ -182,6 +182,8 @@ bool File::isHidden() const throw()
}
//==============================================================================
const char* juce_Argv0 = 0; // referenced from juce_Application.cpp
const File File::getSpecialLocation (const SpecialLocationType type)
{
const ScopedAutoReleasePool pool;
@@ -230,6 +232,11 @@ const File File::getSpecialLocation (const SpecialLocationType type)
return tmp.getFullPathName();
}
case invokedExecutableFile:
if (juce_Argv0 != 0)
return File (String::fromUTF8 ((const uint8*) juce_Argv0));
// deliberate fall-through...
case currentExecutableFile:
return juce_getExecutableFile();


+ 1
- 0
src/native/windows/juce_win32_Files.cpp View File

@@ -489,6 +489,7 @@ const File JUCE_CALLTYPE File::getSpecialLocation (const SpecialLocationType typ
return File (String (dest));
}
case invokedExecutableFile:
case currentExecutableFile:
case currentApplicationFile:
{


Loading…
Cancel
Save