def testInitialize(self): """Tests the __init__ function.""" file_entry = tsk_file_entry.TSKFileEntry(self._resolver_context, self._file_system, self._tsk_path_spec) self.assertIsNotNone(file_entry)
def GetFileEntryByPathSpec(self, path_spec): """Retrieves a file entry for a path specification. Args: path_spec (PathSpec): path specification. Returns: TSKFileEntry: a file entry or None if not available. """ # Opening a file by inode number is faster than opening a file by location. tsk_file = None inode = getattr(path_spec, 'inode', None) location = getattr(path_spec, 'location', None) root_inode = self.GetRootInode() if (location == self.LOCATION_ROOT or (inode is not None and root_inode is not None and inode == root_inode)): tsk_file = self._tsk_file_system.open(self.LOCATION_ROOT) return tsk_file_entry.TSKFileEntry(self._resolver_context, self, path_spec, tsk_file=tsk_file, is_root=True) try: if inode is not None: tsk_file = self._tsk_file_system.open_meta(inode=inode) elif location is not None: tsk_file = self._tsk_file_system.open(location) except IOError: pass if tsk_file is None: return None # TODO: is there a way to determine the parent inode number here? return tsk_file_entry.TSKFileEntry(self._resolver_context, self, path_spec, tsk_file=tsk_file)
def testIntialize(self): """Test the initialize functionality.""" file_entry = tsk_file_entry.TSKFileEntry( self._resolver_context, self._file_system, self._tsk_path_spec) self.assertNotEqual(file_entry, None)