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 |
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
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
|
|
|
|
Goto Forum:
Current Time: Sat Dec 21 15:14:59 CET 2024
Total time taken to generate the page: 0.02995 seconds
|