Beispiel #1
0
  for i in range(0, files_header.count.value):
    e, remains = parse(remains, "entry", [SizedString("name", uint8), beuint32("flags"), beuint32("offset"), beuint32("size"), beuint32("packed_size")])
    entries.append(e)

    source = os.path.join(f.name.value.replace('\\', '/'), e.name.value.replace('\\', '/'))
    target = os.path.join(output, source)
    print '.. extracting %s to %s...' % (source, target)

    if e.flags.value == 64:  # compressed file
      if not os.path.exists(os.path.dirname(target)):
        os.makedirs(os.path.dirname(target))

      with open(target, 'wb') as o:
        i = RawChunk(sys.argv[1], Bounds(e.offset.value, e.offset.value + e.packed_size.value - 1))
        lzss.decompress(i, o)

    elif e.flags.value == 32:  # uncompressed file
      if not os.path.exists(os.path.dirname(target)):
        os.makedirs(os.path.dirname(target))

      with open(target, 'wb') as o:
        i = RawChunk(sys.argv[1], Bounds(e.offset.value, e.offset.value + e.size.value - 1))
        o.write(i.read(None))

    else:
      print e.flags

  print 'read: %d entries' % len(entries)


Beispiel #2
0
print "expecting %d entries" % ((footer.index_offset.value - 32 - footer.filename_size.value) / 24)
print index

output = sys.argv[2]
for e in entries:
  target = os.path.join(output, e.name.value.replace('\\', '/'))
  print '.. extracting %s to %s...' % (e.name.value, target)

  if e.flags.value == 1024: # folder
    if not os.path.exists(target):
      os.makedirs(target)

  elif e.flags.value == 2:  # compressed file
    if not os.path.exists(os.path.dirname(target)):
      os.makedirs(os.path.dirname(target))

    with open(target, 'wb') as o:
      i = RawChunk(sys.argv[1], Bounds(e.data_offset.value, e.data_offset.value + e.compressed_size.value - 1))
      o.write(zlib.decompress(i.read(None)))
  elif e.flags.value == 1:  # uncompressed file
    if not os.path.exists(os.path.dirname(target)):
      os.makedirs(os.path.dirname(target))

    with open(target, 'wb') as o:
      i = RawChunk(sys.argv[1], Bounds(e.data_offset.value, e.data_offset.value + e.compressed_size.value - 1))
      o.write(i.read(None))
  else:
    print e.flags

print 'read: %d entries' % len(entries)