diff options
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(); |