Commits

Anonymous committed ef82a2c

New class Replay. Some explanations about replays content can be found here:
http://code.google.com/p/starcraft2replay/wiki/ReplayDetails

  • Participants
  • Parent commits e555782

Comments (0)

Files changed (4)

                 break
         return None
 
-    def listfiles(self):
-        f = self.findfile("(listfile)")
+    def readfile(self, fname):
+        print fname
+        f = self.findfile(fname)
         if f is None:
+            print "File %s not found in archive" % fname
             return None
         blk = self.blocktable[f.block_index.int()]
-        self.fp.seek(self.archive_offset + blk.file_offset.int())
+        print blk
+        self.fp.seek(blk.file_offset.int() + self.archive_offset)
+
+        if blk.isencrypted():
+            print "decrypt needed"
+
         if blk.iscompressed():
             ct = self.fp.read(1)
             content = self.fp.read(blk.compressed_size.int() - 1)
             if ct == "\x10":
+                print "BZIP2"
                 import bz2
-                print bz2.decompress(content)
+                return bz2.decompress(content)
+            return content
+        return None
+
+    def listfiles(self):
+        content = self.readfile("(listfile)")
+        if content is None:
+            return None
+        for f in content.split('\n'):
+            print f

File definitions.py

     def isencrypted(self):
         return self.__check_flag("encrypted")
 
+    def has_implode(self):
+        return self.__check_flag("implode")

File mpqreader.py

 # -*- coding: utf-8 -*-
 
 import sys
-from archive import *
+from replay import *
 
 if __name__ == "__main__":
     from optparse import OptionParser
         print p.usage
         sys.exit(1)
 
-    a = Archive(args[0])
-    print a.listfiles()
+    rp = Replay(args[0])
+    rp.listfiles()
+    rp.info()
+
     
-
+# -*- coding: utf-8 -*-
+
+from archive import Archive
+
+class Replay(Archive):
+    def info(self):
+        content = self.readfile("replay.details")