Created
April 30, 2013 08:03
-
-
Save feisuzhu/5487274 to your computer and use it in GitHub Desktop.
Arkanoid TVI 'Isles.dat' extractor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
import struct | |
import zlib | |
import os | |
def ensure_dir(f): | |
d = os.path.dirname(f) | |
if not os.path.exists(d): | |
os.makedirs(d) | |
data = open('Isles.dat').read() | |
locations = [m.start() - 3 for m in re.finditer('\x00\xa0\x20\x14\x00', data)] | |
for loc in locations: | |
fnloc, tag, data_till, _ = struct.unpack('<LLLL', data[loc:loc+16]) | |
assert tag == 0x1420a0 | |
fn = data[fnloc:fnloc+30].split('\x00')[0].replace('\\', '/') | |
print fn | |
data_start = fnloc + len(fn) + 1 | |
compressed = data[data_start:data_till-1] | |
content = zlib.decompress(compressed) | |
ensure_dir(fn) | |
open(fn, 'wb').write(content) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment