summaryrefslogtreecommitdiff
path: root/src/utils/physfstools.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-11-01 20:24:09 +0300
committerAndrei Karas <akaras@inbox.ru>2013-11-01 21:33:37 +0300
commit23b307ad13024134908849b53b756dd6073f8d56 (patch)
tree29b02c624c07e49a29ed44962282f61de946324d /src/utils/physfstools.cpp
parente9ddc70c0202c04535c83753bad2d01a92527b15 (diff)
downloadmv-23b307ad13024134908849b53b756dd6073f8d56.tar.gz
mv-23b307ad13024134908849b53b756dd6073f8d56.tar.bz2
mv-23b307ad13024134908849b53b756dd6073f8d56.tar.xz
mv-23b307ad13024134908849b53b756dd6073f8d56.zip
move physfs initialisation code in physfstools.
Diffstat (limited to 'src/utils/physfstools.cpp')
-rw-r--r--src/utils/physfstools.cpp21
1 files changed, 21 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();