Strip the '.gz' extension from the filename that is written to the

gzip header.
This commit is contained in:
Lars Gustäbel 2007-02-13 16:24:00 +00:00
parent 5b1a785702
commit f19c1b5e0e
1 changed files with 6 additions and 3 deletions

View File

@ -149,15 +149,18 @@ class GzipFile:
def _write_gzip_header(self):
self.fileobj.write('\037\213') # magic header
self.fileobj.write('\010') # compression method
fname = self.name
if fname.endswith(".gz"):
fname = fname[:-3]
flags = 0
if self.name:
if fname:
flags = FNAME
self.fileobj.write(chr(flags))
write32u(self.fileobj, long(time.time()))
self.fileobj.write('\002')
self.fileobj.write('\377')
if self.name:
self.fileobj.write(self.name + '\000')
if fname:
self.fileobj.write(fname + '\000')
def _init_read(self):
self.crc = zlib.crc32("")