def testInitialize(self): """Tests the __init__ function.""" file_entry = apfs_file_entry.APFSFileEntry(self._resolver_context, self._file_system, self._apfs_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: APFSFileEntry: file entry or None if not available. Raises: BackEndError: if the file entry cannot be opened. """ # Opening a file by identifier by location will ensure added time is # provided when available. fsapfs_file_entry = None location = getattr(path_spec, 'location', None) identifier = getattr(path_spec, 'identifier', None) if (location == self.LOCATION_ROOT or identifier == self.ROOT_DIRECTORY_IDENTIFIER): fsapfs_file_entry = self._fsapfs_volume.get_root_directory() return apfs_file_entry.APFSFileEntry( self._resolver_context, self, path_spec, fsapfs_file_entry=fsapfs_file_entry, is_root=True) try: if location is not None: fsapfs_file_entry = self._fsapfs_volume.get_file_entry_by_path( location) elif identifier is not None: fsapfs_file_entry = self._fsapfs_volume.get_file_entry_by_identifier( identifier) except IOError as exception: raise errors.BackEndError(exception) if fsapfs_file_entry is None: return None return apfs_file_entry.APFSFileEntry( self._resolver_context, self, path_spec, fsapfs_file_entry=fsapfs_file_entry)