コード例 #1
0
ファイル: pack_brres.py プロジェクト: Heath123/abmatt
 def generateRoot(self, subfiles):
     """ Generates the root folders
         Does not hook up data pointers except the head group,
         returns (rootFolders, bytesize)
     """
     rootFolders = []  # for storing Index Groups
     byteSize = 0
     # Create folder indexing folders
     rootFolder = Folder(self.binfile, 'root')
     rootFolders.append(rootFolder)
     offsets = []  # for tracking offsets from first group to others
     # Create folder for each section the brres has
     for i in range(len(subfiles)):
         folder_name, folder = subfiles[i]
         size = len(folder)
         if size:
             f = Folder(self.binfile, folder_name)
             for j in range(size):
                 f.addEntry(folder[j].name)  # might not have name?
             rootFolder.addEntry(f.name)
             rootFolders.append(f)
             offsets.append(byteSize)
             byteSize += f.byteSize()
     # now update the dataptrs
     rtsize = rootFolder.byteSize()
     entries = rootFolder.entries
     for i in range(len(offsets)):
         entries[i].dataPtr = offsets[i] + rtsize
     return rootFolders
コード例 #2
0
 def recursive_add_unknown(self, parent_dir, node):
     parent_dir.addEntry(node.name)
     if type(node) == UnknownFolder:
         f = Folder(self.binfile, node.name)
         node.folder = f
         for x in node.subfiles:
             self.recursive_add_unknown(f, x)
         return f.byteSize()
     return 0