Skip to content

Extract have something wrong #223

@EunChae1110

Description

@EunChae1110

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions