All pastes #567441 Raw Edit

Cody Brocious

public python v1 · immutable
·published 2007-06-15 00:02 UTC
rendered paste body
import struct, sys, os, zlibdef main(infile, outdir):    fp = file(infile, 'rb')    if fp.read(4) != 'ARC\0':        return 1    flags, count = struct.unpack('<HH', fp.read(4))    files = {}    for i in range(count):        fn = fp.read(64).rstrip('\0')        unk1, length, unk2, offset = struct.unpack('<LLLL', fp.read(16))        files[fn] = (offset, length)    for (fn, (offset, length)) in files.items():        fn = '%s/%s' % (outdir, fn.replace('\\', '/'))        try:            os.makedirs(fn.rsplit('/', 1)[0])        except OSError:            pass        ofp = file(fn, 'wb')        fp.seek(offset)        data = fp.read(length)        data = zlib.decompress(data)                ofp.write(data)                ofp.close()if __name__=='__main__':    sys.exit(main(*(sys.argv[1:])))