diff options
-rw-r--r-- | src/lib/mods.cc | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/src/lib/mods.cc b/src/lib/mods.cc index 07f48da..979ecbf 100644 --- a/src/lib/mods.cc +++ b/src/lib/mods.cc @@ -170,6 +170,7 @@ bool libbible::installModFromZip(string filename) { unzClose(zipfile); return false; } + cout << "Unzipping " << filename << "\n"; char read_buffer[READ_SIZE]; ulong i; for(i = 0; i < global_info.number_entry; i++) { @@ -179,6 +180,7 @@ bool libbible::installModFromZip(string filename) { return false; } string fname = basedir + string(read_buffer); + cout << "Unpacking " << fname << "\n"; size_t pos = fname.find_last_of(delim); if(pos != string::npos) { string path = fname.substr(0, pos); @@ -189,26 +191,28 @@ bool libbible::installModFromZip(string filename) { unzClose(zipfile); return false; } - FILE *out = fopen(fname.c_str(), "wb"); - if(out == NULL) { - unzCloseCurrentFile(zipfile); - unzClose(zipfile); - return false; - } - int bytesRead; - do { - bytesRead = unzReadCurrentFile(zipfile, read_buffer, READ_SIZE); - if(bytesRead < 0) { - printf("error %d\n", bytesRead); + if(pos != fname.size()-1) { // It is not a directory + FILE *out = fopen(fname.c_str(), "wb"); + if(out == NULL) { unzCloseCurrentFile(zipfile); unzClose(zipfile); return false; } - if(bytesRead > 0) { - fwrite(read_buffer, bytesRead, 1, out); - } - } while(bytesRead > 0); - fclose(out); + int bytesRead; + do { + bytesRead = unzReadCurrentFile(zipfile, read_buffer, READ_SIZE); + if(bytesRead < 0) { + printf("error %d\n", bytesRead); + unzCloseCurrentFile(zipfile); + unzClose(zipfile); + return false; + } + if(bytesRead > 0) { + fwrite(read_buffer, bytesRead, 1, out); + } + } while(bytesRead > 0); + fclose(out); + } unzCloseCurrentFile(zipfile); unzGoToNextFile(zipfile); } |