Commits

clach04 committed ec369b4 Draft

Added list and single files extract option.

  • Participants
  • Parent commits a4b4756

Comments (0)

Files changed (2)

 
 For *.SMK movies, see http://www.radgametools.com/smkdown.htm#Smacker for
 players and converters.
+
+Usage:
+
+List files in archive
+
+    detre.py  FullPathToFile.TRE list
+
+Extract single files (to current directory)
+
+    detre.py  FullPathToFile.TRE NUMBER_FROM_LIST
+    
+    # example, extract the first file (file number zero)
+    detre.py  FullPathToFile.TRE 0
+
+Extract all (to current directory)
+
+    detre.py  FullPathToFile.TRE
 # vim:ts=4:sw=4:softtabstop=4:smarttab:expandtab
 #
 """Pure Python version of Janes Longbow 2 detre tool.
-See Longbow 2: TRE extractor by Mario Brito
+See Longbow 2: TRE extractor by Mario Brito.
+
+Usage:
+
+List files in archive
+
+    detre.py  FullPathToFile.TRE list
+
+Extract single files (to current directory)
+
+    detre.py  FullPathToFile.TRE NUMBER_FROM_LIST
+    
+    # example, extract the first file (file number zero)
+    detre.py  FullPathToFile.TRE 0
+
+Extract all (to current directory)
+
+    detre.py  FullPathToFile.TRE
+
 """
 
 import os
         for x in range(self.num_files):
             self.extract(x)
 
-def doit(tre_filename):
+def doit(tre_filename, param=None):
     t = TreFile(tre_filename)
     #t.extract(0)  # first file
-    t.extract_all()
+    if param is None:
+        t.extract_all()
+    elif param == 'list':
+        for x in range(t.num_files):
+            print '%3d %10d  %s' % (x, t.size1[x], t.filenames[x])
+    else:
+        file_num = int(param)
+        t.extract(file_num)
 
 
 def main(argv=None):
     
     tre_filename = argv[1]
     #tre_filename = '/windows/lb2/MOVIES2.TRE'
-    doit(tre_filename)
+    try:
+        param = argv[2]
+    except IndexError:
+        param = None
+    doit(tre_filename, param=param)
     
     return 0