comparison zipfiles/zipfile32.py @ 183:8196d2c0d6f8

Updated zipfiles for Python 3.2.1
author Oleg Oshmyan <chortos@inbox.lv>
date Thu, 14 Jul 2011 18:52:18 +0300
parents 45d4a9dc707b
children
comparison
equal deleted inserted replaced
180:760d38ee86d6 183:8196d2c0d6f8
251 start = data.rfind(stringEndArchive) 251 start = data.rfind(stringEndArchive)
252 if start >= 0: 252 if start >= 0:
253 # found the magic number; attempt to unpack and interpret 253 # found the magic number; attempt to unpack and interpret
254 recData = data[start:start+sizeEndCentDir] 254 recData = data[start:start+sizeEndCentDir]
255 endrec = list(struct.unpack(structEndArchive, recData)) 255 endrec = list(struct.unpack(structEndArchive, recData))
256 comment = data[start+sizeEndCentDir:] 256 commentSize = endrec[_ECD_COMMENT_SIZE] #as claimed by the zip file
257 # check that comment length is correct 257 comment = data[start+sizeEndCentDir:start+sizeEndCentDir+commentSize]
258 if endrec[_ECD_COMMENT_SIZE] == len(comment): 258 endrec.append(comment)
259 # Append the archive comment and start offset 259 endrec.append(maxCommentStart + start)
260 endrec.append(comment) 260
261 endrec.append(maxCommentStart + start) 261 # Try to read the "Zip64 end of central directory" structure
262 262 return _EndRecData64(fpin, maxCommentStart + start - filesize,
263 # Try to read the "Zip64 end of central directory" structure 263 endrec)
264 return _EndRecData64(fpin, maxCommentStart + start - filesize,
265 endrec)
266 264
267 # Unable to find a valid end of central directory structure 265 # Unable to find a valid end of central directory structure
268 return 266 return
269 267
270 268