original_docstring: Loads a .cat file and stores entries in the file tree.
          The entries will reference the .dat file.
          Returns True if the .cat file is parsed and loaded sucessfully.
          This function will NOT override already existing entries.
  
          Arguments:
          cat_path: path to .cat file.
          dat_path: path to .dat file.
          
docstring: Loads a .cat file and stores entries in the file tree.
  The entries will reference the .dat file.
  Returns True if the .cat file is parsed and loaded sucessfully.
  This function will NOT override already existing entries.
  
  path to .cat file.
  dat_path: path to .dat file.
docstring_tokens: Loads a . cat file and stores entries in the file tree . The entries will reference the . dat file . Returns True if the . cat file is parsed and loaded sucessfully . This function will NOT override already existing entries . path to . cat file . dat_path : path to . dat file .
code: def _load_cat_file(self, cat_path, dat_path):
          """Loads a .cat file and stores entries in the file tree.
          The entries will reference the .dat file.
          Returns True if the .cat file is parsed and loaded sucessfully.
          This function will NOT override already existing entries.
  
          Arguments:
          cat_path: path to .cat file.
          dat_path: path to .dat file.
          """
          file_offset = 0
          entries = []
  
          LOG.info('Loading .cat file %s', cat_path)
  
          # first parse entries
          # if the cat file is malformed this block will return, so the file
          # won't be partially loaded
          with open(cat_path, 'r') as cat_file:
              for line_no, line in enumerate(cat_file):
                  if not line:
                      continue
  
                  # match 'path size timestamp hash' format
                  # path might contain spaces, so a rsplit is needed
                  parts = line.lower().rsplit(' ', 3)
                  if len(parts) != 4:
                      LOG.error('Cat file %s has invalid entry on line %s',
                                cat_path, line_no + 1)
                      return False
  
                  game_path = split_game_path(parts[0])
                  size = int(parts[1])
                  offset = file_offset
                  file_offset += size
  
                  if not game_path:
                      LOG.error('Cat file %s contains malformed game file path '
                                '%s on line %s', cat_path, parts[0], line_no + 1)
                      continue
  
                  file_name = game_path[-1]
                  game_path = game_path[:-1]
  
                  entries.append((
                      game_path,
                      CatEntry(dat_path, file_name, size, offset)
                  ))
  
          file_tree = self.file_tree
  
          # now add entries to the file tree
          for (game_path, entry) in entries:
              k = file_tree
  
              for directory in game_path:
                  if directory not in k.children:
                      k.children[directory] = DirNode()
  
                  k = k.children[directory]
  
              if entry.name not in k.children:
                  k.children[entry.name] = entry
  
          self.loaded.add(cat_path)
  
          return True
code_tokens: def _load_cat_file ( self , cat_path , dat_path ) : file_offset = 0 entries = [ ] LOG . info ( 'Loading .cat file %s' , cat_path ) with open ( cat_path , 'r' ) as cat_file : for line_no , line in enumerate ( cat_file ) : if not line : continue parts = line . lower ( ) . rsplit ( ' ' , 3 ) if len ( parts ) != 4 : LOG . error ( 'Cat file %s has invalid entry on line %s' , cat_path , line_no + 1 ) return False game_path = split_game_path ( parts [ 0 ] ) size = int ( parts [ 1 ] ) offset = file_offset file_offset += size if not game_path : LOG . error ( 'Cat file %s contains malformed game file path ' '%s on line %s' , cat_path , parts [ 0 ] , line_no + 1 ) continue file_name = game_path [ - 1 ] game_path = game_path [ : - 1 ] entries . append ( ( game_path , CatEntry ( dat_path , file_name , size , offset ) ) ) file_tree = self . file_tree for ( game_path , entry ) in entries : k = file_tree for directory in game_path : if directory not in k . children : k . children [ directory ] = DirNode ( ) k = k . children [ directory ] if entry . name not in k . children : k . children [ entry . name ] = entry self . loaded . add ( cat_path ) return True
short_docstring: Loads a .cat file and stores entries in the file tree.
short_docstring_tokens: Loads a . cat file and stores entries in the file tree .
comment: """Loads a .cat file and stores entries in the file tree.
          The entries will reference the .dat file.
          Returns True if the .cat file is parsed and loaded sucessfully.
          This function will NOT override already existing entries.
  
          Arguments:
          cat_path: path to .cat file.
          dat_path: path to .dat file.
          """$SEP$# first parse entries$SEP$# if the cat file is malformed this block will return, so the file$SEP$# won't be partially loaded$SEP$# match 'path size timestamp hash' format$SEP$# path might contain spaces, so a rsplit is needed$SEP$# now add entries to the file tree