1
0
mirror of https://github.com/moparisthebest/minetest synced 2024-11-10 11:25:07 -05:00

Fix .zip extraction (mod store)

This commit is contained in:
ngosang 2015-01-22 17:09:29 +01:00 committed by Craig Robbins
parent c7249f5983
commit 878e9f7594

View File

@ -863,15 +863,15 @@ int ModApiMainMenu::l_extract_zip(lua_State *L)
std::string fullpath = destination; std::string fullpath = destination;
fullpath += DIR_DELIM; fullpath += DIR_DELIM;
fullpath += files_in_zip->getFullFileName(i).c_str(); fullpath += files_in_zip->getFullFileName(i).c_str();
std::string fullpath_dir = fs::RemoveLastPathComponent(fullpath);
if (files_in_zip->isDirectory(i)) { if (!files_in_zip->isDirectory(i)) {
if (! fs::CreateAllDirs(fullpath) ) { if (!fs::PathExists(fullpath_dir) && !fs::CreateAllDirs(fullpath_dir)) {
fs->removeFileArchive(fs->getFileArchiveCount()-1); fs->removeFileArchive(fs->getFileArchiveCount()-1);
lua_pushboolean(L,false); lua_pushboolean(L,false);
return 1; return 1;
} }
}
else {
io::IReadFile* toread = opened_zip->createAndOpenFile(i); io::IReadFile* toread = opened_zip->createAndOpenFile(i);
FILE *targetfile = fopen(fullpath.c_str(),"wb"); FILE *targetfile = fopen(fullpath.c_str(),"wb");
@ -883,7 +883,7 @@ int ModApiMainMenu::l_extract_zip(lua_State *L)
} }
char read_buffer[1024]; char read_buffer[1024];
unsigned int total_read = 0; long total_read = 0;
while (total_read < toread->getSize()) { while (total_read < toread->getSize()) {