summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorngosang <diegodelasheras@gmail.com>2015-01-22 17:09:29 +0100
committerCraig Robbins <kde.psych@gmail.com>2015-02-14 21:00:13 +1000
commit878e9f759481948af73e5129c5a79e44425a534e (patch)
treeeb9b43501b55840c36779c5d0078fa9426ad39ad
parentc7249f59833c42faf5407108a25bd65bae893b95 (diff)
downloadminetest-878e9f759481948af73e5129c5a79e44425a534e.tar.gz
minetest-878e9f759481948af73e5129c5a79e44425a534e.tar.bz2
minetest-878e9f759481948af73e5129c5a79e44425a534e.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()) {