MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / _EndRecData64

Function _EndRecData64

tools/python-3.11.9-amd64/Lib/zipfile.py:242–282  ·  view source on GitHub ↗

Read the ZIP64 end-of-archive records and use that to update endrec

(fpin, offset, endrec)

Source from the content-addressed store, hash-verified

240 return result
241
242def _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
285def _EndRecData(fpin):

Callers 1

_EndRecDataFunction · 0.85

Calls 4

BadZipFileClass · 0.85
seekMethod · 0.45
readMethod · 0.45
unpackMethod · 0.45

Tested by

no test coverage detected