#!/usr/bin/python # This program reads in the Krondor.001 resource file used by Betrayal at # Krondor and writes all the files contained in it to the current directory. # silsor, March 2004 # rewritten 30/12/04 import struct import sys if len(sys.argv) != 2: print """Usage: unchunk.py datafile where datafile is the name of the file you want unchunked. Will dump all files into the current directory.""" sys.exit() try: chunkFile = open(sys.argv[1], 'r') except IOError: print "Could not open file %s for reading." % sys.argv[1] sys.exit(-1) fileCount = 0 # filename is DOS 8.3 format, stored in 13 bytes, null padded fileName = chunkFile.read(13).strip('\x00') while fileName != '': fileCount += 1 # file size is stored four bytes, little-endian fileSize = int(struct.unpack('