CodecZlib.jl
CodecZlib.jl copied to clipboard
How to write valid empty gzip file?
How should one proceed to generate a valid empty gzip file using CodecZlib?
Here is what I tried:
import CodecZlib
gz = CodecZlib
fh = gz.GzipCompressorStream(open("test_out.gz", "w"))
close(fh)
However, the following results in an empty file (zero bytes) that gzip cannot handle properly:
$ zcat test_out.gz
gzip: test_out.gz: unexpected end of file
$
I can generate valid gzipped file using Python:
>>> from gzip import open as gzopen
>>> with gzopen("test_out.gz", "w") as fh:
... pass
...
The resulting file is not really empty (a few bytes), and gzip does not complain when I try to zcat it:
$ zcat test_out.gz
$