geromueller / zstream-cpp

C++ zip stream wrapper
43 stars 5 forks source link

Created .gz-archive not correct? #4

Open BorysLysyansky opened 2 years ago

BorysLysyansky commented 2 years ago

I have tried to start an example output_test.cpp:

include "ozstream.hpp"

include \<fstream>

int main(void) { std::ofstream os("test.txt.gz"); zstream::ogzstream gz(os); for (size_t i = 0; i < 2000; i++) gz << i << std::endl; return 0; } compiled it with the: g++ -I.. zlib1.dll output_test.cpp have run the binary: ./a.exe The file test.txt.gz was created, but as I've tried to unzip it with:

gzip.exe -d test.txt.gz

I've got an error: gzip: test.txt.gz: invalid compressed data--length error

What does it mean? Is it possible to decompress the obtained file with some "standard" software?

Borys

geromueller commented 1 year ago

Hi, sorry for the late reply. I can not reproduce your error. If you still have the error, could you try to add a gz.close() after the loop?

BorysLysyansky commented 1 year ago

Dear Gero,

unfortunatelly, it did not help:

I have used the following output_test.cpp file with the smaller output:

include "ozstream.hpp"

include \<fstream>

int main(void) { std::ofstream os("test.txt.gz"); zstream::ogzstream gz(os); for (size_t i = 0; i < 5; i++) gz << i << std::endl; gz.close(); return 0; }

and have got the following test.txt.gz file (32 bytes): First 16 Symbols: 1F 8B 08 00 00 00 00 00 00 03 33 E0 32 E4 32 E2 Second 16 Symbols: 32 E6 32 E1 02 00 0D 0A 1A B4 44 0D 0A 00 00 00

If I try to perform the command: gunzip.exe test.txt.gz, I got the following error messages:

gunzip: test.txt.gz: invalid compressed data--crc error gunzip: test.txt.gz: invalid compressed data--length error

Could you, please, have a look?

Borys