From: ngosang Date: Thu, 22 Jan 2015 16:09:29 +0000 (+0100) Subject: Fix .zip extraction (mod store) X-Git-Tag: 0.4.12~14 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=878e9f759481948af73e5129c5a79e44425a534e;p=oweals%2Fminetest.git Fix .zip extraction (mod store) --- 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()) {