bguise987 / pigz-python

The goal of this project is to create a pure Python implementation of the pigz project for parallelizing gzipping.
MIT License
31 stars 5 forks source link

Add FNAME FLG #12

Closed bguise987 closed 4 years ago

bguise987 commented 4 years ago

Gzip and pigz both add FNAME to the header (FLG bit 3)

See http://www.zlib.org/rfc-gzip.html#header-trailer

bguise987 commented 4 years ago

This bit of code from the gzip module seems relevant:

try:
            # RFC 1952 requires the FNAME field to be Latin-1. Do not
            # include filenames that cannot be represented that way.
            fname = os.path.basename(self.name)
            if not isinstance(fname, bytes):
                fname = fname.encode('latin-1')
            if fname.endswith(b'.gz'):
                fname = fname[:-3]
        except UnicodeEncodeError:
            fname = b''
        flags = 0
        if fname:
            flags = FNAME