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) » Zip with no compression
Zip with no compression [message #46022] Fri, 19 February 2016 15:52 Go to next message
WebChaot is currently offline  WebChaot
Messages: 53
Registered: September 2006
Location: Austria, Vienna
Member
Hi all!

Wanted to implement to save some data in "native" format, like Open Document (ods, odt, ...) or the MS equivalent Office Open XML Format (xlsx, docx, ...).

All of these "files" are ZIP-Files with some XML-Files packed in. The problem is, that in both formats one file needs to be in the archive which must not be compressed.

I tried around with the ZIP-class - but no success. Last try was, that I added a new Function and only changed the compression flag to false. But I got allways errors on Test Platform (https://odf-validator.rhcloud.com/). Allways got CRC-Error - sometimes CRC 0, sometimes CRC is not like expected.

I also tried many other things (BeginFile, Put, EndFile, and so on) - but I guess (and hope), this simple adaption should do the work. I hope, I only forgot one simple thing and the it does what it want Smile



void Zip::WriteFileUncompressed(const void *ptr, int size, const char *path, Gate2<int, int> progress, Time tm)
{
	ASSERT(!IsFileOpened());
	File& f = file.Add();
	StringStream ss;
	MemReadStream ms(ptr, size);

	f.crc = 0;

	f.usize = size;
	zPress(ss, ms, size, AsGate64(progress), false, false, &f.crc, false);

	String data = ss.GetResult();
	const void *r = ~data;
	f.csize = data.GetLength();

	f.version = 21;
	f.gpflag = 0;
	f.method = 0;
	
	FileHeader(path, tm);
	zip->Put(r, f.csize);
	done += f.csize;
	if (zip->IsError()) WhenError(); 
}




Thanks a lot,

WebChaot
Re: Zip with no compression [message #46078 is a reply to message #46022] Mon, 29 February 2016 18:30 Go to previous message
mirek is currently offline  mirek
Messages: 14162
Registered: November 2005
Ultimate Member
I have altered plugin/zip - critical methods (BegingFile and WriteFile) now have one last parameter 'deflate' - set it to false to store file uncompressed.

Mirek
Previous Topic: Eigen updated and new FFT demo included
Next Topic: Can't build a basic Skylark app! Help!
Goto Forum:
  


Current Time: Fri Dec 13 22:25:49 CET 2024

Total time taken to generate the page: 0.03424 seconds