ctr_romfs: add support for reading L3 only

This commit is contained in:
xprism1 2023-08-22 00:28:14 +08:00
parent 2417b6831d
commit 1865b2831c

View File

@ -118,9 +118,11 @@ def calc_path_hash(name, parent_off):
return h return h
class RomFSReader: class RomFSReader:
def __init__(self, file): def __init__(self, file, lvl3only=False):
self.file = file self.file = file
self.lvl3only = lvl3only
if not lvl3only:
with open(file, 'rb') as f: with open(file, 'rb') as f:
self.hdr = RomFSHdr(f.read(0x5C)) self.hdr = RomFSHdr(f.read(0x5C))
@ -157,6 +159,8 @@ class RomFSReader:
curr += hashes['Level 2']['size'] curr += hashes['Level 2']['size']
self.hashes = hashes self.hashes = hashes
else:
self.lvl3_offset = 0
# Parse level 3 (actual data) # Parse level 3 (actual data)
self.files = {} self.files = {}
@ -216,6 +220,7 @@ class RomFSReader:
print(f'Extracted to {output_dir}') print(f'Extracted to {output_dir}')
def verify(self): def verify(self):
if not self.lvl3only:
f = open(self.file, 'rb') f = open(self.file, 'rb')
hash_check = [] hash_check = []