2021-03-17 15:53:31 +01:00
|
|
|
#!/usr/bin/env python3
|
2016-11-23 06:35:12 +01:00
|
|
|
|
|
|
|
import sys, os, os.path, struct
|
|
|
|
import pywii as wii
|
|
|
|
|
|
|
|
fstb = wii.WiiFSTBuilder(0x20)
|
|
|
|
|
|
|
|
fstb.addfrom(sys.argv[2])
|
|
|
|
|
2021-03-17 15:53:31 +01:00
|
|
|
try:
|
|
|
|
arc = open(sys.argv[1],"wb")
|
|
|
|
# dummy generate to get length
|
|
|
|
fstlen = len(fstb.fst.generate())
|
|
|
|
dataoff = wii.align(0x20+fstlen,0x20)
|
|
|
|
fst = fstb.fst.generate(dataoff)
|
2016-11-23 06:35:12 +01:00
|
|
|
|
2021-03-17 15:53:31 +01:00
|
|
|
hdr = struct.pack(">IIII16x",0x55AA382d,0x20,fstlen,dataoff)
|
|
|
|
arc.write(hdr)
|
2016-11-23 06:35:12 +01:00
|
|
|
|
2021-03-17 15:53:31 +01:00
|
|
|
arc.write(fst)
|
2016-11-23 06:35:12 +01:00
|
|
|
wii.falign(arc,0x20)
|
2021-03-17 15:53:31 +01:00
|
|
|
for f in fstb.files:
|
|
|
|
data = open(f, "rb").read()
|
|
|
|
arc.write(data)
|
|
|
|
wii.falign(arc,0x20)
|
2016-11-23 06:35:12 +01:00
|
|
|
|
2021-03-17 15:53:31 +01:00
|
|
|
arc.close()
|
|
|
|
except:
|
|
|
|
os.remove(sys.argv[1])
|
|
|
|
raise
|