mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-29 22:48:30 +00:00
Added SDL_GetSandbox()
This adds support for detecting whether you're running in a sandbox on macOS
This commit is contained in:
38
src/SDL.c
38
src/SDL.c
@@ -753,6 +753,44 @@ bool SDL_IsTV(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
static SDL_Sandbox SDL_DetectSandbox(void)
|
||||
{
|
||||
#if defined(SDL_PLATFORM_LINUX)
|
||||
if (access("/.flatpak-info", F_OK) == 0) {
|
||||
return SDL_SANDBOX_FLATPAK;
|
||||
}
|
||||
|
||||
/* For Snap, we check multiple variables because they might be set for
|
||||
* unrelated reasons. This is the same thing WebKitGTK does. */
|
||||
if (SDL_getenv("SNAP") && SDL_getenv("SNAP_NAME") && SDL_getenv("SNAP_REVISION")) {
|
||||
return SDL_SANDBOX_SNAP;
|
||||
}
|
||||
|
||||
if (access("/run/host/container-manager", F_OK) == 0) {
|
||||
return SDL_SANDBOX_UNKNOWN;
|
||||
}
|
||||
|
||||
#elif defined(SDL_PLATFORM_MACOS)
|
||||
if (SDL_getenv("APP_SANDBOX_CONTAINER_ID")) {
|
||||
return SDL_SANDBOX_MACOS;
|
||||
}
|
||||
#endif
|
||||
|
||||
return SDL_SANDBOX_NONE;
|
||||
}
|
||||
|
||||
SDL_Sandbox SDL_GetSandbox(void)
|
||||
{
|
||||
static SDL_Sandbox sandbox;
|
||||
static bool sandbox_initialized;
|
||||
|
||||
if (!sandbox_initialized) {
|
||||
sandbox = SDL_DetectSandbox();
|
||||
sandbox_initialized = true;
|
||||
}
|
||||
return sandbox;
|
||||
}
|
||||
|
||||
#ifdef SDL_PLATFORM_WIN32
|
||||
|
||||
#if (!defined(HAVE_LIBC) || defined(__WATCOMC__)) && !defined(SDL_STATIC_LIB)
|
||||
|
Reference in New Issue
Block a user