Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Library : Other (not classified elsewhere) » Is there a Zip/UnZip example?
Re: Is there a Zip/UnZip example? [message #37333 is a reply to message #37330] Sun, 23 September 2012 09:34 Go to previous messageGo to previous message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

CppMod wrote on Sun, 23 September 2012 03:14

I found the zip.h file, but I was looking for a complete example program that does zip and/or unzip. The threads in this forum are rather old, and have some broken links.

Anyone have some zip/unzip code they are willing to share?

Hi Howard,

In plugin/zip package are some handy classes for zip format. It can be used like this:
#include <plugin/zip/zip.h>
using namespace Upp;

CONSOLE_APP_MAIN{
	// Compression
	FileZip zip("/tmp/test.zip");
	const char* somedata="some data";
	String otherdata="other data";
	zip.WriteFolder("test", GetSysTime());
	zip.WriteFile(somedata, strlen(somedata), "somedata.txt");
	zip.WriteFile(otherdata, "test/otherdata.txt");
	if(zip.Finish())
		Cout() << "Zip created succesfully\n";
	
	// Decompression
	FileUnZip unzip("/tmp/test.zip");
	while (!(unzip.IsEof() || unzip.IsError())) {
		Cout() << "Path:" << unzip.GetPath() << "\n";
		Cout() << "  Time:" << unzip.GetTime() << "\n";
		if(!unzip.IsFolder()){
			Cout() << "  Size:" << unzip.GetLength() << "\n";
			Cout() << "  Content:" << unzip.ReadFile() << "\n";
		} else
			unzip.SkipFile();
	}
}


Aside from FileZip and FileUnZip there are also in-memory variants StringZip, StringUnZip and MemUnZip that don't read/write files from disk. Their usage is very similar.

Best regards,
Honza
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Regexp is not working
Next Topic: How does widget/variable destruction in U++ work?
Goto Forum:
  


Current Time: Tue May 07 06:39:50 CEST 2024

Total time taken to generate the page: 0.02772 seconds