MCPcopy Index your code
hub / github.com/vm03/payload_dumper / bsdf2_read_patch

Function bsdf2_read_patch

payload_dumper.py:43–72  ·  view source on GitHub ↗

read a bsdiff/BSDF2-format patch from stream 'fi'

(fi)

Source from the content-addressed store, hash-verified

41
42# Adapted from bsdiff4.read_patch
43def bsdf2_read_patch(fi):
44 """read a bsdiff/BSDF2-format patch from stream 'fi'
45 """
46 magic = fi.read(8)
47 if magic == bsdiff4.format.MAGIC:
48 # bsdiff4 uses bzip2 (algorithm 1)
49 alg_control = alg_diff = alg_extra = 1
50 elif magic[:5] == BSDF2_MAGIC:
51 alg_control = magic[5]
52 alg_diff = magic[6]
53 alg_extra = magic[7]
54 else:
55 raise ValueError("incorrect magic bsdiff/BSDF2 header")
56
57 # length headers
58 len_control = bsdiff4.core.decode_int64(fi.read(8))
59 len_diff = bsdiff4.core.decode_int64(fi.read(8))
60 len_dst = bsdiff4.core.decode_int64(fi.read(8))
61
62 # read the control header
63 bcontrol = bsdf2_decompress(alg_control, fi.read(len_control))
64 tcontrol = [(bsdiff4.core.decode_int64(bcontrol[i:i + 8]),
65 bsdiff4.core.decode_int64(bcontrol[i + 8:i + 16]),
66 bsdiff4.core.decode_int64(bcontrol[i + 16:i + 24]))
67 for i in range(0, len(bcontrol), 24)]
68
69 # read the diff and extra blocks
70 bdiff = bsdf2_decompress(alg_diff, fi.read(len_diff))
71 bextra = bsdf2_decompress(alg_extra, fi.read())
72 return len_dst, tcontrol, bdiff, bextra
73
74def verify_contiguous(exts):
75 blocks = 0

Callers 1

data_for_opFunction · 0.85

Calls 1

bsdf2_decompressFunction · 0.85

Tested by

no test coverage detected