Gzip



 Gzip (GNU zip) is a compression utility.

File format
The gzip file (.gz) format consists of:
 * a file header
 * optional headers
 * extra fields
 * original file name
 * comment
 * header checksum
 * compressed data (commonly used compression method DEFLATE, without zlib header)
 * a file footer

File header
The file header is 10 bytes in size and contains:

Flags
Notes:
 * Reserved flags bits must be zero.
 * The FHCRC bit was never set by versions of gzip up to 1.2.4, even though it was documented with a different meaning in gzip 1.2.4.

Compression flags
This value contains flags specific to the compression method.

Compression flags - deflate
If compression method value is 8 (deflate) the following compression flags can be used:

Extra fields
This value is present in the file if the FEXTRA flag is set in the file header flags.

The extra field are variable of size and contains:

Original file name
This value is present in the file if the FNAME flag is set in the file header flags.

This is the original name of the file being compressed, with any directory components removed, and, if the file being compressed is on a file system with case insensitive names, forced to lower case.

Contains an ISO 8859-1 (LATIN-1) string with end-of-string character.

Comment
This value is present in the file if the FCOMMENT flag is set in the file header flags.

Contains an ISO 8859-1 (LATIN-1) string with end-of-string character. Line breaks should be denoted by a single line feed character.

Header checksum
The header checksum contain a CRC-16 that consists of the two least significant bytes of the CRC-32 for all bytes of the gzip header up to and not including the CRC-16.

File footer
The file footer is 8 bytes in size and contains: