Fix #15059 Compile in presence for discord (#15063)

Also relying on $TMPDIR is problematic because Discord uses
NSTemporaryDirectory() which may not be the same.
This commit is contained in:
warmenhoven 2023-03-06 13:57:08 -05:00 committed by GitHub
parent b59cd4fcd8
commit a60249ff87
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 1 deletions

View File

@ -9,6 +9,10 @@
#include <sys/un.h>
#include <unistd.h>
#if defined(OSX)
extern "C" void CFTemporaryDirectory(char *s, size_t len);
#endif
struct BaseConnectionUnix : public BaseConnection {
int sock{-1};
};
@ -23,12 +27,18 @@ static int MsgFlags = 0;
static const char* GetTempPath(void)
{
#if defined(OSX)
static char temp[1024];
CFTemporaryDirectory(temp, 1024);
return temp;
#else
const char* temp = getenv("XDG_RUNTIME_DIR");
temp = temp ? temp : getenv("TMPDIR");
temp = temp ? temp : getenv("TMP");
temp = temp ? temp : getenv("TEMP");
temp = temp ? temp : "/tmp";
return temp;
#endif
}
/*static*/ BaseConnection* BaseConnection::Create()

View File

@ -139,7 +139,7 @@ static void CFSearchPathForDirectoriesInDomains(
CFStringGetCString(array_val, s, len, kCFStringEncodingUTF8);
}
static void CFTemporaryDirectory(char *s, size_t len)
void CFTemporaryDirectory(char *s, size_t len)
{
#if __has_feature(objc_arc)
CFStringRef path = (__bridge CFStringRef)NSTemporaryDirectory();

View File

@ -1692,5 +1692,8 @@ STEAM INTEGRATION USING MIST
#ifdef HAVE_MIST
#include "../steam/steam.c"
#include "../tasks/task_steam.c"
#endif
#ifdef HAVE_PRESENCE
#include "../network/presence.c"
#endif

View File

@ -57,6 +57,7 @@ OTHER_CFLAGS = $(inherited) -DHAVE_OPENGL_CORE
OTHER_CFLAGS = $(inherited) -DHAVE_OVERLAY
OTHER_CFLAGS = $(inherited) -DHAVE_OZONE
OTHER_CFLAGS = $(inherited) -DHAVE_PATCH
OTHER_CFLAGS = $(inherited) -DHAVE_PRESENCE
OTHER_CFLAGS = $(inherited) -DHAVE_RBMP
OTHER_CFLAGS = $(inherited) -DHAVE_REWIND
OTHER_CFLAGS = $(inherited) -DHAVE_RGUI