mirror of https://github.com/zeldaret/mm.git
35 lines
1.0 KiB
Python
35 lines
1.0 KiB
Python
import os, struct, sys, ast, argparse
|
|
|
|
def read_uint32_be(offset):
|
|
return struct.unpack('>I', fileData[offset:offset+4])[0]
|
|
|
|
def read_uint16_be(offset):
|
|
return struct.unpack('>H', fileData[offset:offset+2])[0]
|
|
|
|
|
|
if __name__ == "__main__":
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument('files', help='file list')
|
|
parser.add_argument('out', help='output file')
|
|
args = parser.parse_args()
|
|
|
|
with open(args.out, 'wb') as w, open(args.files, 'rt') as f:
|
|
file_name = f.readline().strip()
|
|
total_size = 0
|
|
|
|
while file_name:
|
|
try:
|
|
with open(file_name, 'rb') as current_file:
|
|
file_data = current_file.read()
|
|
w.write(file_data)
|
|
total_size += len(file_data)
|
|
except:
|
|
print('Could not open file ' + file_name)
|
|
sys.exit(1)
|
|
file_name = f.readline().strip()
|
|
|
|
while total_size < 0x2000000:
|
|
w.write((total_size % 256).to_bytes(1,"big"))
|
|
total_size += 1
|
|
|