From 23b307ad13024134908849b53b756dd6073f8d56 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 1 Nov 2013 20:24:09 +0300 Subject: move physfs initialisation code in physfstools. --- src/utils/physfstools.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/utils/physfstools.cpp') 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 +#include + #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(); -- cgit v1.2.3-60-g2f50