Python zlib gzopen














































Python zlib gzopen



In the previous article I have discussed about gzclose function .If you missed it then please go to this given link Python zlib gzclose();
This article will specifically gives you a brief idea about gzopen function

gzopen- gzFile gzopen (const char *path , const char *mode );
The gzopen is used to open a compressed fileThe gzopen() function shall open the compressed file named by path. The mode argument is based on that of fopen(), but the mode parameter may also contain the following characters:
digit
set the compression level to digit. A low value (e.g. 1) means high speed, while a high value (e.g. 9) means high compression. A compression level of 0 (zero) means no compression. See defaultInit2_() for further details.

[fhR]
set the compression strategy to [fhR]. The letter f corresponds to filtered data, the letter h corresponds to Huffman only compression, and the letter R corresponds to Run Length Encoding. See defaultInit2_() for further details.

If path refers to an uncompressed file, and mode refers to a read mode, gzopen() shall attempt to open the file and return a gzFile object suitable for reading directly from the file without any decompression.
If path or mode is NULL, or if mode does not contain one of r, w, or a, gzopen() shall return Z_NULL, and need not set any other error condition.
The gzFile object is also referred to as a compressed file stream.
Example
gzopen("file.gz", "w6h");
Attempt to create a new compressed file, file.gz, at compression level 6 using Huffman only compression.
Return Value
On success, gzopen() shall return a gzFile object (also known as a compressed file stream). On failure, gzopen() shall return Z_NULL and may set errno accordingly.
At version 1.2.2, zlib does not set errno for several error conditions. Applications may not be able to determine the cause of an error.
On error, gzopen() may set the global variable errno to indicate the error.


Comments