mirror of
https://github.com/elliotnunn/machfs.git
synced 2024-11-22 04:31:37 +00:00
Read extents overflow file
This commit is contained in:
parent
e3d3623de9
commit
eb847a97cd
@ -125,8 +125,12 @@ class Volume(directory.AbstractFolder):
|
||||
extoflow = {}
|
||||
for rec in btree.dump_btree(extrec2bytes(drXTExtRec)):
|
||||
if rec[0] != 7: continue
|
||||
# print(key, val)
|
||||
pass
|
||||
xkrFkType, xkrFNum, xkrFABN, extrec = struct.unpack_from('>xBLH12s', rec)
|
||||
if xkrFkType == 0xFF:
|
||||
fork = 'rsrc'
|
||||
elif xkrFkType == 0:
|
||||
fork = 'data'
|
||||
extoflow[xkrFNum, fork, xkrFABN] = extrec
|
||||
|
||||
cnids = {}
|
||||
childlist = [] # list of (parent_cnid, child_name, child_object) tuples
|
||||
@ -176,17 +180,12 @@ class Volume(directory.AbstractFolder):
|
||||
f.type, f.creator, f.flags, f.x, f.y = struct.unpack_from('>4s4sHHH', filUsrWds)
|
||||
|
||||
for fork, length, extrec in [('data', filLgLen, filExtRec), ('rsrc', filRLgLen, filRExtRec)]:
|
||||
accum = bytearray()
|
||||
extrec = list(struct.unpack('>HHHHHH', extrec))
|
||||
extrec = list(zip(extrec[::2], extrec[1::2]))
|
||||
for extstart, extlength in extrec:
|
||||
if extlength == 0: continue
|
||||
astart = 512*drAlBlSt + drAlBlkSiz*extstart
|
||||
astop = astart + drAlBlkSiz*extlength
|
||||
accum.extend(from_volume[astart:astop])
|
||||
accum = bytearray(extrec2bytes(extrec))
|
||||
while len(accum) < length:
|
||||
next_blk = len(accum) // drAlBlkSiz
|
||||
next_extrec = extoflow[filFlNum, fork, next_blk]
|
||||
accum.extend(extrec2bytes(next_extrec))
|
||||
del accum[length:] # logical length can be less than a number of blocks
|
||||
if len(accum) != length:
|
||||
raise ValueError('need to consult extents overflow file')
|
||||
|
||||
setattr(f, fork, accum)
|
||||
|
||||
|
11
test_all.py
11
test_all.py
@ -51,6 +51,11 @@ def test_macos_mount():
|
||||
os.system('umount /Volumes/ElmoTest')
|
||||
assert recovered == hf.data
|
||||
|
||||
# h2 = Volume()
|
||||
# h2.read(ser)
|
||||
# assert h2['testfile-000'].data == hf.data
|
||||
h2 = Volume()
|
||||
h2.read(ser)
|
||||
assert h2['testfile-000'].data == hf.data
|
||||
|
||||
def test_extents_overflow():
|
||||
h = Volume()
|
||||
h.read(open('SourceForEmulator.dmg','rb').read())
|
||||
assert h['aa'].data == b'a' * 278528
|
||||
|
Loading…
Reference in New Issue
Block a user