diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-11-01 20:24:09 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-11-01 21:33:37 +0300 |
commit | 23b307ad13024134908849b53b756dd6073f8d56 (patch) | |
tree | 29b02c624c07e49a29ed44962282f61de946324d /src/utils/physfstools.cpp | |
parent | e9ddc70c0202c04535c83753bad2d01a92527b15 (diff) | |
download | manaverse-23b307ad13024134908849b53b756dd6073f8d56.tar.gz manaverse-23b307ad13024134908849b53b756dd6073f8d56.tar.bz2 manaverse-23b307ad13024134908849b53b756dd6073f8d56.tar.xz manaverse-23b307ad13024134908849b53b756dd6073f8d56.zip |
move physfs initialisation code in physfstools.
Diffstat (limited to 'src/utils/physfstools.cpp')
-rw-r--r-- | src/utils/physfstools.cpp | 21 |
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(); |