Read the ZIP64 end-of-archive records and use that to update endrec
(fpin, offset, endrec)
| 240 | return result |
| 241 | |
| 242 | def _EndRecData64(fpin, offset, endrec): |
| 243 | """ |
| 244 | Read the ZIP64 end-of-archive records and use that to update endrec |
| 245 | """ |
| 246 | try: |
| 247 | fpin.seek(offset - sizeEndCentDir64Locator, 2) |
| 248 | except OSError: |
| 249 | # If the seek fails, the file is not large enough to contain a ZIP64 |
| 250 | # end-of-archive record, so just return the end record we were given. |
| 251 | return endrec |
| 252 | |
| 253 | data = fpin.read(sizeEndCentDir64Locator) |
| 254 | if len(data) != sizeEndCentDir64Locator: |
| 255 | return endrec |
| 256 | sig, diskno, reloff, disks = struct.unpack(structEndArchive64Locator, data) |
| 257 | if sig != stringEndArchive64Locator: |
| 258 | return endrec |
| 259 | |
| 260 | if diskno != 0 or disks > 1: |
| 261 | raise BadZipFile("zipfiles that span multiple disks are not supported") |
| 262 | |
| 263 | # Assume no 'zip64 extensible data' |
| 264 | fpin.seek(offset - sizeEndCentDir64Locator - sizeEndCentDir64, 2) |
| 265 | data = fpin.read(sizeEndCentDir64) |
| 266 | if len(data) != sizeEndCentDir64: |
| 267 | return endrec |
| 268 | sig, sz, create_version, read_version, disk_num, disk_dir, \ |
| 269 | dircount, dircount2, dirsize, diroffset = \ |
| 270 | struct.unpack(structEndArchive64, data) |
| 271 | if sig != stringEndArchive64: |
| 272 | return endrec |
| 273 | |
| 274 | # Update the original endrec using data from the ZIP64 record |
| 275 | endrec[_ECD_SIGNATURE] = sig |
| 276 | endrec[_ECD_DISK_NUMBER] = disk_num |
| 277 | endrec[_ECD_DISK_START] = disk_dir |
| 278 | endrec[_ECD_ENTRIES_THIS_DISK] = dircount |
| 279 | endrec[_ECD_ENTRIES_TOTAL] = dircount2 |
| 280 | endrec[_ECD_SIZE] = dirsize |
| 281 | endrec[_ECD_OFFSET] = diroffset |
| 282 | return endrec |
| 283 | |
| 284 | |
| 285 | def _EndRecData(fpin): |
no test coverage detected