aspose.info
EN

GZ File Format - GNU Zipped Archive File

Updated

What is a GZ file?

A GZ file is a compressed archive that is created using the standard gzip (GNU zip) compression algorithm. It may contain multiple compressed files, directories and file stubs. This format was initially developed to replace compression formats on UNIX systems. and is still one of the most common archive types on Linux systems. Applications such as WinZip can open GZ files to view its contents on both Windows and MacOS.

GZ File Format - More Information

Gzip uses the DEFLATE algorithm for compression of archive and differs from the ZIP archive format in applying the compression algorithm on complete archive rather than individual files. The GZIP file format specifications version 4.3 published by Internet Engineering Task Force (IETF) contains detailed information about the file format. The file format consists of:

  • File Header
  • Optional Headers
  • Compressed Data
  • File Footer

GZ File Header

The GZ file header consists of 10 bytes as follow:

OffsetSizeValueDescription
020x1f 0x8bMagic number identifying file type
21Compression Method * 0-7 (Reserved) * 8 (Deflate)
31File Flags
4432-bit timestamp
81Compression flags
91Operating system ID

File Flags

ValueIdentifierDescription
0x01FTEXTIf set the uncompressed data needs to be treated as text instead of binary data. This flag hints end-of-line conversion for cross-platform text files but does not enforce it.
0x02FHCRCThe file contains a header checksum (CRC-16)
0x04FEXTRAThe file contains extra fields
0x08FNAMEThe file contains an original file name string
0x10FCOMMENTThe file contains comment
0x20Reserved
0x40Reserved
0x80Reserved

Operating System

ValueDescription
0FAT filesystem (MS-DOS, OS/2, NT/Win32)
1Amiga
2VMS (or OpenVMS)
3Unix
4VM/CMS
5Atari TOS
6HPFS filesystem (OS/2, NT)
7Macintosh
8Z-System
9CP/M
10TOPS-20
11NTFS filesystem (NT)
12QDOS
13Acorn RISCOS
255unknown

GZ Optional Headers

The optional extra headers are those as denoted by the file flags and include information such as the original filename, extra fields, comments and header checksum.

Compressed Data

This section contains the compressed data using the DEFLATE compression algorithm.

The file footer is 8 bytes in size and contains following information.

OffsetSizeDescription
04Checksum (CRC-32)
44Uncompressed data size value in bytes

References

See also