[physfs] Allow physfs to compile on 3DS
Vladimir Serbinenko
phcoder at google.com
Tue Mar 17 17:19:42 EDT 2020
Pasting as inline because attachment got deleted
commit 9d09f17f8f2200bf23eea9b8fabc0ef3a1dd4d16
Author: Vladimir Serbinenko <phcoder at google.com>
Date: Tue Mar 17 14:04:21 2020 +0100
Support for 3DS
diff --git a/src/physfs_platform_posix.c b/src/physfs_platform_posix.c
index fa2159c..90fff5f 100644
--- a/src/physfs_platform_posix.c
+++ b/src/physfs_platform_posix.c
@@ -58,6 +58,7 @@ static inline PHYSFS_ErrorCode errcodeFromErrno(void)
} /* errcodeFromErrno */
+#ifndef PHYSFS_HARDCODED_HOME
static char *getUserDirByUID(void)
{
uid_t uid = getuid();
@@ -83,10 +84,13 @@ static char *getUserDirByUID(void)
return retval;
} /* getUserDirByUID */
-
+#endif
char *__PHYSFS_platformCalcUserDir(void)
{
+#ifdef PHYSFS_HARDCODED_HOME
+ return strdup(PHYSFS_HARDCODED_HOME);
+#else
char *retval = NULL;
char *envr = getenv("HOME");
@@ -115,6 +119,7 @@ char *__PHYSFS_platformCalcUserDir(void)
retval = getUserDirByUID();
return retval;
+#endif
} /* __PHYSFS_platformCalcUserDir */
@@ -334,6 +339,7 @@ int __PHYSFS_platformStat(const char *fname,
PHYSFS_Stat *st, const int follow)
return 1;
} /* __PHYSFS_platformStat */
+#include "ctr_pthread.h"
typedef struct
{
diff --git a/src/physfs_platform_unix.c b/src/physfs_platform_unix.c
index 10d93a7..7a81f39 100644
--- a/src/physfs_platform_unix.c
+++ b/src/physfs_platform_unix.c
@@ -213,7 +213,7 @@ static char *findBinaryInPath(const char *bin, char *envr)
return NULL; /* doesn't exist in path. */
} /* findBinaryInPath */
-
+#ifndef PHYSFS_HARDCODED_BASE_DIR
static char *readSymLink(const char *path)
{
ssize_t len = 64;
@@ -244,10 +244,13 @@ static char *readSymLink(const char *path)
allocator.Free(retval);
return NULL;
} /* readSymLink */
-
+#endif
char *__PHYSFS_platformCalcBaseDir(const char *argv0)
{
+#ifdef PHYSFS_HARDCODED_BASE_DIR
+ return strdup (PHYSFS_HARDCODED_BASE_DIR);
+#else
char *retval = NULL;
const char *envr = NULL;
@@ -329,6 +332,7 @@ char *__PHYSFS_platformCalcBaseDir(const char *argv0)
} /* if */
return retval;
+#endif
} /* __PHYSFS_platformCalcBaseDir */
diff --git a/src/physfs_platforms.h b/src/physfs_platforms.h
index d4e4bfd..96d5854 100644
--- a/src/physfs_platforms.h
+++ b/src/physfs_platforms.h
@@ -72,6 +72,13 @@
#elif defined(unix) || defined(__unix__)
# define PHYSFS_PLATFORM_UNIX 1
# define PHYSFS_PLATFORM_POSIX 1
+#elif defined(_3DS)
+# define PHYSFS_NO_CDROM_SUPPORT 1
+# define PHYSFS_PLATFORM_UNIX 1
+# define PHYSFS_PLATFORM_POSIX 1
+# define PHYSFS_HARDCODED_HOME "sdmc:/"
+# define PHYSFS_HARDCODED_BASE_DIR "sdmc:/"
+# define lstat stat
#else
# error Unknown platform.
#endif
On Tue, Mar 17, 2020, 22:17 Vladimir Serbinenko <phcoder at google.com> wrote:
> This allows the port of the game engine chailove to Nintendo 3DD
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://icculus.org/pipermail/physfs/attachments/20200317/1bd6817a/attachment.htm>
More information about the physfs
mailing list