1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-17 00:44:19 +00:00

Cache the result of isRunningInAppExtensionSandbox

This commit is contained in:
hogliux 2016-09-30 12:33:37 +01:00
parent 495e2bfd56
commit bf85f4c68b

View file

@ -191,16 +191,26 @@ void SystemStats::setApplicationCrashHandler (CrashHandlerFunction handler)
bool SystemStats::isRunningInAppExtensionSandbox() noexcept
{
#if JUCE_MAC || JUCE_IOS
File bundle = File::getSpecialLocation (File::invokedExecutableFile).getParentDirectory();
#if JUCE_MAC || JUCE_IOS
static bool firstQuery = true;
static bool isRunningInAppSandbox = false;
#if JUCE_MAC
bundle = bundle.getParentDirectory().getParentDirectory();
#endif
if (firstQuery)
{
firstQuery = false;
if (bundle.isDirectory())
return (bundle.getFileExtension() == ".appex");
#endif
File bundle = File::getSpecialLocation (File::invokedExecutableFile).getParentDirectory();
#if JUCE_MAC
bundle = bundle.getParentDirectory().getParentDirectory();
#endif
if (bundle.isDirectory())
isRunningInAppSandbox = (bundle.getFileExtension() == ".appex");
}
return isRunningInAppSandbox;
#else
return false;
#endif
}