aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorngosang <diegodelasheras@gmail.com>2015-01-22 17:09:29 +0100
committerLoic Blot <loic.blot@unix-experience.fr>2015-02-12 15:27:20 +0100
commite102cbd840c3dc3d52865868369aea3b8ee21028 (patch)
tree5a5037f96e5f6b43488cb2fe795b33218d8713fe
parent146f77fdb750833c649de7159a0833c398e14a4d (diff)
downloadminetest-e102cbd840c3dc3d52865868369aea3b8ee21028.tar.gz
minetest-e102cbd840c3dc3d52865868369aea3b8ee21028.tar.bz2
minetest-e102cbd840c3dc3d52865868369aea3b8ee21028.zip
Fix .zip extraction (mod store)
-rw-r--r--src/script/lua_api/l_mainmenu.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/script/lua_api/l_mainmenu.cpp b/src/script/lua_api/l_mainmenu.cpp
index 28c3d193d..0d8365106 100644
--- a/src/script/lua_api/l_mainmenu.cpp
+++ b/src/script/lua_api/l_mainmenu.cpp
@@ -859,19 +859,19 @@ int ModApiMainMenu::l_extract_zip(lua_State *L)
unsigned int number_of_files = files_in_zip->getFileCount();
- for (unsigned int i=0; i < number_of_files; i++) {
+ for (unsigned int i=0; i < number_of_files; i++) {
std::string fullpath = destination;
fullpath += DIR_DELIM;
fullpath += files_in_zip->getFullFileName(i).c_str();
+ std::string fullpath_dir = fs::RemoveLastPathComponent(fullpath);
- if (files_in_zip->isDirectory(i)) {
- if (! fs::CreateAllDirs(fullpath) ) {
+ if (!files_in_zip->isDirectory(i)) {
+ if (!fs::PathExists(fullpath_dir) && !fs::CreateAllDirs(fullpath_dir)) {
fs->removeFileArchive(fs->getFileArchiveCount()-1);
lua_pushboolean(L,false);
return 1;
}
- }
- else {
+
io::IReadFile* toread = opened_zip->createAndOpenFile(i);
FILE *targetfile = fopen(fullpath.c_str(),"wb");
@@ -883,7 +883,7 @@ int ModApiMainMenu::l_extract_zip(lua_State *L)
}
char read_buffer[1024];
- unsigned int total_read = 0;
+ long total_read = 0;
while (total_read < toread->getSize()) {