From: Finn B. <bc...@us...> - 2001-10-06 20:40:26
|
Update of /cvsroot/jython/jython/Lib In directory usw-pr-cvs1:/tmp/cvs-serv10144 Modified Files: zipfile.py Log Message: Use the zipfile.py from CPython-2.2. It contain a different but better workaround for the problems that CPython-2.1-zipfile.py had. Index: zipfile.py =================================================================== RCS file: /cvsroot/jython/jython/Lib/zipfile.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** zipfile.py 2001/07/18 10:27:11 1.1 --- zipfile.py 2001/10/06 20:40:23 1.2 *************** *** 30,35 **** structFileHeader = "<4s2B4H3l2H" # 12 items, file header record, 30 bytes stringFileHeader = "PK\003\004" # magic number for file header - structExtHeader = "<4s3l" # 4 items, extra header record, 16 bytes - stringExtHeader = "PK\007\010" # magic number for ext header # indexes of entries in the central directory structure --- 30,33 ---- *************** *** 84,88 **** if endrec[0:4] == "PK\005\006" and endrec[-2:] == "\000\000": return 1 # file has correct magic number ! except IOError: pass --- 82,86 ---- if endrec[0:4] == "PK\005\006" and endrec[-2:] == "\000\000": return 1 # file has correct magic number ! except: pass *************** *** 375,385 **** self._writecheck(zinfo) fp = open(filename, "rb") ! zinfo.flag_bits = 0x08 zinfo.header_offset = self.fp.tell() # Start of header bytes self.fp.write(zinfo.FileHeader()) zinfo.file_offset = self.fp.tell() # Start of file bytes - CRC = 0 - compress_size = 0 - file_size = 0 if zinfo.compress_type == ZIP_DEFLATED: cmpr = zlib.compressobj(zlib.Z_DEFAULT_COMPRESSION, --- 373,384 ---- self._writecheck(zinfo) fp = open(filename, "rb") ! zinfo.flag_bits = 0x00 zinfo.header_offset = self.fp.tell() # Start of header bytes + # Must overwrite CRC and sizes with correct data later + zinfo.CRC = CRC = 0 + zinfo.compress_size = compress_size = 0 + zinfo.file_size = file_size = 0 self.fp.write(zinfo.FileHeader()) zinfo.file_offset = self.fp.tell() # Start of file bytes if zinfo.compress_type == ZIP_DEFLATED: cmpr = zlib.compressobj(zlib.Z_DEFAULT_COMPRESSION, *************** *** 407,413 **** zinfo.CRC = CRC zinfo.file_size = file_size ! # Write CRC and file sizes after the file data ! self.fp.write(struct.pack(structExtHeader, stringExtHeader, ! zinfo.CRC, zinfo.compress_size, zinfo.file_size)) self.filelist.append(zinfo) self.NameToInfo[zinfo.filename] = zinfo --- 406,415 ---- zinfo.CRC = CRC zinfo.file_size = file_size ! # Seek backwards and write CRC and file sizes ! position = self.fp.tell() # Preserve current position in file ! self.fp.seek(zinfo.header_offset + 14, 0) ! self.fp.write(struct.pack("<lll", zinfo.CRC, zinfo.compress_size, ! zinfo.file_size)) ! self.fp.seek(position, 0) self.filelist.append(zinfo) self.NameToInfo[zinfo.filename] = zinfo *************** *** 432,437 **** if zinfo.flag_bits & 0x08: # Write CRC and file sizes after the file data ! self.fp.write(struct.pack(structExtHeader, stringExtHeader, ! zinfo.CRC, zinfo.compress_size, zinfo.file_size)) self.filelist.append(zinfo) self.NameToInfo[zinfo.filename] = zinfo --- 434,439 ---- if zinfo.flag_bits & 0x08: # Write CRC and file sizes after the file data ! self.fp.write(struct.pack("<lll", zinfo.CRC, zinfo.compress_size, ! zinfo.file_size)) self.filelist.append(zinfo) self.NameToInfo[zinfo.filename] = zinfo |