libzippp
libzippp copied to clipboard
Extract have something wrong
I use libzippp to make extract. This is the code:
void ExtractZip(std::string path)
{
ZipArchive zip(path);
zip.open(ZipArchive::ReadOnly);
std::vector<ZipEntry> entries = zip.getEntries();
std::vector<ZipEntry>::iterator it;
path = "./"+path.substr(0, path.find(".zip"));
std::filesystem::create_directory(path);
for (it = entries.begin(); it != entries.end(); ++it)
{
ZipEntry entry = *it;
if (entry.isDirectory())
{
std::filesystem::create_directories(path+"\\"+entry.getName());
}
std::ofstream unzippedFile(path + "\\"+entry.getName());
entry.readContent(unzippedFile);
unzippedFile.close();
}
zip.close();
}
However, when I checked the file after extracted, the file destroyed.
Original file:
After extract: