libzippp icon indicating copy to clipboard operation
libzippp copied to clipboard

Extract have something wrong

Open EunChae1110 opened this issue 6 months ago • 4 comments

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: image After extract: image

EunChae1110 avatar Jan 09 '24 16:01 EunChae1110