Skip to content

The c++ interface to operate ZIP files. No libraries required. Just one header and one c file.

Notifications You must be signed in to change notification settings

AndrewShpagin/zpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

zpp

CMake

The c++ interface to operate ZIP files. No libraries required. Just one header and one c file.

It is based on miniz - https://code.google.com/archive/p/miniz/ (completely free)

Including into your project

Just add miniz.c and zpp.h into your project. Include zpp.h and use the classes defined there. No any library required!

How to use?

Look the zipFileWriter and zipFileReader, the interfaces are self-obvious. Examples of usage

  1. Create zip from the folder
zipFileWriter z("output_path.zip");
z.addFolder("./folder_to_zip/");
z.flush();
  1. Add single file to ZIP
zipFileWriter z("output_path.zip");
z.addFile("./some_path/filename.txt", "path_in_archive.txt");
z.flush();
  1. Add string/raw data as the record in the ZIP file.
zipFileWriter z("output_path.zip");
z.addString("The text to be ziped", "path_in_archive.txt");
z.flush();
  1. Extract the whole archive
zipFileReader r("path_to_archive.zip");
r.extractAll("./output_path/");
  1. Extract single file (the first one in the ZIP). It is helpful if the ZIP contains just one file.
zipFileReader r("path_to_archive.zip");
r.extractFirstToFile("destination_path_for_single_file.txt");
  1. List all files, extract only required files
zipFileReader r("path_to_archive.zip");
auto list = r.getFilesList();
for (auto e = list.begin(); e != list.end(); e++) {
	std::cout << e->c_str() << "\n";
	std::filesystem::path p = "./extract_path/";
	p.append(e->c_str());
	r.extractToFile(e->c_str(), p.generic_u8string()); 
}

Licensing

Completely free. Look https://code.google.com/archive/p/miniz/

About

The c++ interface to operate ZIP files. No libraries required. Just one header and one c file.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published