summaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/physfstools.cpp21
-rw-r--r--src/utils/physfstools.h1
2 files changed, 22 insertions, 0 deletions
diff --git a/src/utils/physfstools.cpp b/src/utils/physfstools.cpp
index cf87fa9ab..36131759b 100644
--- a/src/utils/physfstools.cpp
+++ b/src/utils/physfstools.cpp
@@ -20,12 +20,33 @@
#include "utils/physfstools.h"
+#include <iostream>
+#include <unistd.h>
+
#include "localconsts.h"
const char *dirSeparator = nullptr;
namespace PhysFs
{
+ void init(const char *const name)
+ {
+#if defined(__native_client__)
+ if (!PHYSFS_init("/fakebinary"))
+#elif defined(ANDROID)
+ if (!PHYSFS_init((getRealPath(".").append("/fakebinary")).c_str()))
+#else
+ if (!PHYSFS_init(name))
+#endif
+ {
+ std::cout << "Error while initializing PhysFS: "
+ << PHYSFS_getLastError() << std::endl;
+ _exit(1);
+ }
+ updateDirSeparator();
+ atexit((void(*)()) PHYSFS_deinit);
+ }
+
void updateDirSeparator()
{
dirSeparator = PHYSFS_getDirSeparator();
diff --git a/src/utils/physfstools.h b/src/utils/physfstools.h
index cb64a981b..fd760f287 100644
--- a/src/utils/physfstools.h
+++ b/src/utils/physfstools.h
@@ -25,6 +25,7 @@
namespace PhysFs
{
+ void init(const char *const name);
void updateDirSeparator();
const char *getDirSeparator();
const char *getBaseDir();