Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
macOS: load game files from ~/Library/Application Support/re3
- Loading branch information
Showing
with
41 additions
and
6 deletions.
-
+3
−3
src/core/CdStreamPosix.cpp
-
+30
−2
src/core/FileMgr.cpp
-
+3
−1
src/core/FileMgr.h
-
+5
−0
src/core/config.h
There are no files selected for viewing
|
|
@@ -17,7 +17,7 @@ |
|
|
#include "CdStream.h" |
|
|
#include "rwcore.h" |
|
|
#include "RwHelper.h" |
|
|
#ifdef XDG_ROOT |
|
|
#if defined(XDG_ROOT) || defined(APPSUPPORT_ROOT) |
|
|
#include "FileMgr.h" |
|
|
#endif |
|
|
|
|
|
@@ -148,9 +148,9 @@ void |
|
|
CdStreamInit(int32 numChannels) |
|
|
{ |
|
|
struct statvfs fsInfo; |
|
|
char imgPath[128] = {'\0'}; |
|
|
char imgPath[PATH_MAX] = {'\0'}; |
|
|
|
|
|
#ifdef XDG_ROOT |
|
|
#if defined(XDG_ROOT) || defined(APPSUPPORT_ROOT) |
|
|
const char *rootDir = CFileMgr::GetRootDirName(); |
|
|
strncpy(imgPath, rootDir, strlen(rootDir) - 1); |
|
|
strcat(imgPath, "/"); |
|
|
|
|
|
@@ -8,6 +8,11 @@ |
|
|
|
|
|
#include "FileMgr.h" |
|
|
|
|
|
#ifdef APPSUPPORT_ROOT |
|
|
#include <crt_externs.h> |
|
|
#include <sysdir.h> |
|
|
#endif |
|
|
|
|
|
const char *_psGetUserFilesFolder(); |
|
|
|
|
|
/* |
|
|
@@ -197,7 +202,10 @@ myfeof(int fd) |
|
|
char CFileMgr::ms_rootDirName[128] = {'\0'}; |
|
|
char CFileMgr::ms_dirName[128]; |
|
|
|
|
|
#ifdef XDG_ROOT |
|
|
#if defined(XDG_ROOT) || defined(APPSUPPORT_ROOT) |
|
|
#ifdef __APPLE__ |
|
|
#define environ (*_NSGetEnviron()) |
|
|
#endif |
|
|
#define getenvvar(varName) \ |
|
|
char **p = environ; \ |
|
|
size_t varNameLength = ARRAY_SIZE(varName) - 1; \ |
|
|
@@ -214,10 +222,12 @@ void CFileMgr::GetHomeDirectory(char *homeDir) { |
|
|
getenvvar("HOME"); |
|
|
} |
|
|
|
|
|
#ifdef XDG_ROOT |
|
|
void CFileMgr::GetXDGDataHome(char *homeDir) { |
|
|
getenvvar("XDG_DATA_HOME"); |
|
|
} |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
void |
|
|
CFileMgr::Initialise(void) |
|
|
@@ -251,6 +261,24 @@ CFileMgr::Initialise(void) |
|
|
} |
|
|
} |
|
|
strcpy(ms_rootDirName, homeDir); |
|
|
#elif defined(APPSUPPORT_ROOT) |
|
|
char path[PATH_MAX], homeDir[PATH_MAX]; |
|
|
struct stat buf; |
|
|
bzero(path, PATH_MAX); |
|
|
bzero(homeDir, PATH_MAX); |
|
|
GetHomeDirectory(homeDir); |
|
|
assert(homeDir[0] != '\0'); |
|
|
sysdir_search_path_enumeration_state state = sysdir_start_search_path_enumeration(SYSDIR_DIRECTORY_APPLICATION_SUPPORT, SYSDIR_DOMAIN_MASK_USER); |
|
|
while ((state = sysdir_get_next_search_path_enumeration(state, path)) != 0) { |
|
|
assert(path[0] != '\0'); |
|
|
strcat(homeDir, path + 1); |
|
|
strcat(homeDir, "/re3"); |
|
|
break; |
|
|
} |
|
|
if (stat(homeDir, &buf) < 0) { |
|
|
assert(mkdir(homeDir, 0755) == 0); |
|
|
} |
|
|
strcpy(ms_rootDirName, homeDir); |
|
|
#else |
|
|
_getcwd(ms_rootDirName, 128); |
|
|
#endif |
|
|
@@ -317,7 +345,7 @@ CFileMgr::LoadFile(const char *file, uint8 *buf, int unused, const char *mode) |
|
|
int |
|
|
CFileMgr::OpenFile(const char *file, const char *mode) |
|
|
{ |
|
|
#ifdef XDG_ROOT |
|
|
#if defined(XDG_ROOT) || defined(APPSUPPORT_ROOT) |
|
|
char fixedPath[128] = {'\0'}; |
|
|
bzero(fixedPath, 128); |
|
|
if (ms_dirName[0] == '\0') { |
|
|
|
|
|
@@ -20,8 +20,10 @@ class CFileMgr |
|
|
static int CloseFile(int fd); |
|
|
static int GetErrorReadWrite(int fd); |
|
|
static char *GetRootDirName() { return ms_rootDirName; } |
|
|
#ifdef XDG_ROOT |
|
|
#if defined(XDG_ROOT) || defined(APPSUPPORT_ROOT) |
|
|
static void GetHomeDirectory(char *homeDir); |
|
|
#endif |
|
|
#ifdef XDG_ROOT |
|
|
static void GetXDGDataHome(char *homeDir); |
|
|
#endif |
|
|
}; |
|
|
@@ -314,3 +314,8 @@ enum Config { |
|
|
|
|
|
// Store GTA 3 files in ${HOME}/.local/share/re3 |
|
|
// #define XDG_ROOT |
|
|
|
|
|
#ifdef __APPLE__ |
|
|
// Store GTA 3 files in ${HOME}/Library/Application Support/re3 |
|
|
// #define APPSUPPORT_ROOT |
|
|
#endif |