Fixed Parsing Error in scrapper.py

This commit is contained in:
Earthnuker 2017-10-08 03:05:53 +02:00
parent 79889722ac
commit 50541eadb1

View file

@ -23,14 +23,11 @@ PackedHeader = Struct(
Const(b'BFPK'), Const(b'BFPK'),
Const(b'\0\0\0\0'), Const(b'\0\0\0\0'),
'files'/PrefixedArray(Int32ul,ScrapFile), 'files'/PrefixedArray(Int32ul,ScrapFile),
'offset'/Tell,
) )
DummyHeader = Struct( DummyHeader = Struct(
Const(b'BFPK'), Const(b'BFPK'),
Const(b'\0\0\0\0'), Const(b'\0\0\0\0'),
'files_cnt'/Rebuild(Int32ul,len_(this.files)),
'files'/PrefixedArray(Int32ul,DummyFile), 'files'/PrefixedArray(Int32ul,DummyFile),
'offset'/Tell,
) )
parser = argparse.ArgumentParser(description='Unpack and Repack .packed files') parser = argparse.ArgumentParser(description='Unpack and Repack .packed files')
parser.add_argument('-u', '--unpack', action='store_true', parser.add_argument('-u', '--unpack', action='store_true',
@ -90,7 +87,7 @@ if options.unpack:
print('Unpacking {}'.format(os.path.basename(packed_file))) print('Unpacking {}'.format(os.path.basename(packed_file)))
with open(packed_file, 'rb') as pkfile: with open(packed_file, 'rb') as pkfile:
data = PackedHeader.parse_stream(pkfile) data = PackedHeader.parse_stream(pkfile)
print("Offset:",hex(data.offset)) print("Offset:",hex(pkfile.tell()))
for file in tqdm(data.files,ascii=True): for file in tqdm(data.files,ascii=True):
folder, filename = os.path.split(file.path) folder, filename = os.path.split(file.path)
if folder: if folder: