// second argument of unzLocateFile: 1 = case sensitive, 0 = case-insensitive
SETTING_TRACE("File %s not found in %s", fileInZip, zipFile);
unzCloseCurrentFile(uf); // close the zipfile
+ unzClose(uf);
return -1;
} // file inside zip found
- if (unzGetCurrentFileInfo(uf, &file_info, filename_inzip, sizeof(filename_inzip), NULL, 0, NULL, 0)) {
+ err = unzGetCurrentFileInfo(uf, &file_info, filename_inzip, sizeof(filename_inzip), NULL, 0, NULL, 0);
+ if (err != UNZ_OK) {
SETTING_TRACE("Error %d with zipfile %s in unzGetCurrentFileInfo.", err, zipFile);
unzCloseCurrentFile(uf); // close the zipfile
+ unzClose(uf);
return -1;
} // obtained the necessary details about file inside zip
if (buf == NULL) {
SETTING_TRACE("Error allocating memory for read buffer");
unzCloseCurrentFile(uf); // close the zipfile
+ unzClose(uf);
return -1;
} // buffer ready
SETTING_TRACE("Error %d with zipfile %s in unzOpenCurrentFilePassword.", err, zipFile);
free(buf);
unzCloseCurrentFile(uf); // close the zipfile
+ unzClose(uf);
return -1;
} // file inside the zip is open
SETTING_TRACE("Error to write tempfile : %s", tempfilename);
free(buf);
unzCloseCurrentFile(uf); // close the zipfile
+ unzClose(uf);
return -1;
} // open temp file
}
// copy the buffer to a string
if (err > 0) {
- //for (int i = 0; i < (int) err; i++)
- //sout.push_back( *(((char*)buf)+i) );
fwrite(buf, sizeof(char), err, tempfile_fp);
}
} while (err > 0);
- err = unzCloseCurrentFile(uf); // close the zipfile
- if (err != UNZ_OK)
- SETTING_TRACE("Error %d with zipfile %s in unzCloseCurrentFile", err, zipFile);
+ unzCloseCurrentFile(uf); // close the zipfile
+ unzClose(uf);
free(buf); // free up buffer memory