blob: 49a405649b45eb01ba831bc9334c164cd138010b [file] [log] [blame]
diff --git a/physfs_platforms.h b/physfs_platforms.h
--- a/physfs_platforms.h
+++ b/physfs_platforms.h
@@ -38,7 +38,7 @@
# endif
#elif defined(macintosh)
# error Classic Mac OS support was dropped from PhysicsFS 2.0. Move to OS X.
-#elif defined(unix) || defined(__unix__)
+#elif defined(unix) || defined(__unix__) || defined(__native_client__)
# define PHYSFS_PLATFORM_UNIX
# define PHYSFS_PLATFORM_POSIX
#else
diff --git a/platform/posix.c b/platform/posix.c
--- a/platform/posix.c
+++ b/platform/posix.c
@@ -27,6 +27,11 @@
#include <linux/unistd.h>
#endif
+#if defined(__native_client__) && !defined(__GLIBC__)
+// Newlib doesn't define lstat.
+#define lstat stat
+#endif
+
#include "physfs_internal.h"
diff --git a/platform/unix.c b/platform/unix.c
--- a/platform/unix.c
+++ b/platform/unix.c
@@ -283,8 +283,13 @@ char *__PHYSFS_platformRealPath(const char *path)
char resolved_path[MAXPATHLEN];
char *retval = NULL;
+#if defined(__native_client__) && !defined(__GLIBC__)
+ // TODO(binji): Real implementation for Newlib.
+ strncpy(resolved_path, path, MAXPATHLEN);
+#else
errno = 0;
BAIL_IF_MACRO(!realpath(path, resolved_path), strerror(errno), NULL);
+#endif
retval = (char *) allocator.Malloc(strlen(resolved_path) + 1);
BAIL_IF_MACRO(retval == NULL, ERR_OUT_OF_MEMORY, NULL);
strcpy(retval, resolved_path);