summaryrefslogtreecommitdiff
path: root/src/client.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-09-24 17:13:50 +0300
committerAndrei Karas <akaras@inbox.ru>2013-09-24 17:13:50 +0300
commit5a1214d380a96fa0a1eeeb07a4bfedeae982051a (patch)
tree1e03e4038894d780853228e7ca7fa400c85faa4b /src/client.cpp
parent672dae7a96ae07638a961fb6c8c41117dd8c5c95 (diff)
downloadmv-5a1214d380a96fa0a1eeeb07a4bfedeae982051a.tar.gz
mv-5a1214d380a96fa0a1eeeb07a4bfedeae982051a.tar.bz2
mv-5a1214d380a96fa0a1eeeb07a4bfedeae982051a.tar.xz
mv-5a1214d380a96fa0a1eeeb07a4bfedeae982051a.zip
Extract data.zip on SDL2 and Android before use.
Add file untils class. For now used only for Android.
Diffstat (limited to 'src/client.cpp')
-rw-r--r--src/client.cpp47
1 files changed, 9 insertions, 38 deletions
diff --git a/src/client.cpp b/src/client.cpp
index e96fd370b..7717d1e4b 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -102,6 +102,7 @@
#include "resources/resourcemanager.h"
#include "utils/cpu.h"
+#include "utils/files.h"
#include "utils/fuzzer.h"
#include "utils/gettext.h"
#include "utils/mkdir.h"
@@ -384,7 +385,13 @@ void Client::gameInit()
#ifdef ANDROID
#ifdef USE_SDL2
extractAssets();
- extractLocale();
+
+ const std::string zipName = std::string(getenv(
+ "APPDIR")).append("/data.zip");
+ const std::string dirName = std::string(getenv(
+ "APPDIR")).append("/data");
+ Files::extractZip(zipName, "data", dirName);
+ Files::extractLocale();
#endif
#endif
@@ -534,7 +541,7 @@ void Client::gameInit()
if (getenv("APPDIR"))
{
resman->addToSearchPath(std::string(getenv("APPDIR"))
- + "/data.zip", false);
+ + "/data", false);
}
#endif
#endif
@@ -3296,41 +3303,5 @@ void Client::extractAssets()
delete [] buf;
}
-
-void Client::extractLocale()
-{
- // in future need also remove all locales in local dir
-
- const std::string fileName2 = std::string(getenv(
- "APPDIR")).append("/locale.zip");
- const ResourceManager *const resman = ResourceManager::getInstance();
- resman->addToSearchPath(fileName2, false);
-
- const std::string localDir = std::string(getenv("APPDIR")).append("/");
- char **rootDirs = PhysFs::enumerateFiles("locale");
- for (char **i = rootDirs; *i; i++)
- {
- const std::string dir = std::string("locale/").append(*i);
- if (PhysFs::isDirectory(dir.c_str()))
- {
- const std::string moFile = dir + "/LC_MESSAGES/manaplus.mo";
- if (PhysFs::exists((moFile).c_str()))
- {
- const std::string localFile = localDir + moFile;
- const std::string localDir2 = localDir + dir + "/LC_MESSAGES";
- int size = 0;
- mkdir_r(localDir2.c_str());
- void *const buf = ResourceManager::loadFile(moFile, size);
- FILE *const file = fopen(localFile.c_str(), "w");
- fwrite(buf, 1, size, file);
- fclose(file);
- free(buf);
- }
- }
- }
- PhysFs::freeList(rootDirs);
- resman->removeFromSearchPath(fileName2);
- remove(fileName2.c_str());
-}
#endif
#endif