How to use the dfvfs.resolver.resolver.Resolver.OpenFileSystem function in dfvfs

To help you get started, we’ve selected a few dfvfs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github log2timeline / plaso / plaso / cli / image_export_tool.py View on Github external
resolver_context (dfvfs.Context): resolver context.

    Returns:
      tuple: containing:

        dfvfs.FileSystem: file system.
        dfvfs.PathSpec: mount point path specification that refers
            to the base location of the file system.

    Raises:
      RuntimeError: if source path specification is not set.
    """
    if not source_path_spec:
      raise RuntimeError('Missing source.')

    file_system = path_spec_resolver.Resolver.OpenFileSystem(
        source_path_spec, resolver_context=resolver_context)

    type_indicator = source_path_spec.type_indicator
    if path_spec_factory.Factory.IsSystemLevelTypeIndicator(type_indicator):
      mount_point = source_path_spec
    else:
      mount_point = source_path_spec.parent

    return file_system, mount_point
github log2timeline / plaso / plaso / engine / engine.py View on Github external
tuple: containing:

        dfvfs.FileSystem: file system
        path.PathSpec: mount point path specification. The mount point path
            specification refers to either a directory or a volume on a storage
            media device or image. It is needed by the dfVFS file system
            searcher (FileSystemSearcher) to indicate the base location of
            the file system.

    Raises:
      RuntimeError: if source file system path specification is not set.
    """
    if not source_path_spec:
      raise RuntimeError('Missing source path specification.')

    file_system = path_spec_resolver.Resolver.OpenFileSystem(
        source_path_spec, resolver_context=resolver_context)

    type_indicator = source_path_spec.type_indicator
    if path_spec_factory.Factory.IsSystemLevelTypeIndicator(type_indicator):
      mount_point = source_path_spec
    else:
      mount_point = source_path_spec.parent

    return file_system, mount_point
github log2timeline / dfvfs / dfvfs / volume / vshadow_volume_system.py View on Github external
def Open(self, path_spec):
    """Opens a volume object defined by path specification.

    Args:
      path_spec (PathSpec): a path specification.

    Raises:
      VolumeSystemError: if the VSS virtual file system could not be resolved.
    """
    self._file_system = resolver.Resolver.OpenFileSystem(path_spec)
    if self._file_system is None:
      raise errors.VolumeSystemError('Unable to resolve path specification.')

    type_indicator = self._file_system.type_indicator
    if type_indicator != definitions.TYPE_INDICATOR_VSHADOW:
      raise errors.VolumeSystemError('Unsupported type indicator.')
github libyal / winreg-kb / shellfolder.py View on Github external
volume_identifiers = self._scanner.GetVolumeIdentifiers(volume_system)
    if not volume_identifiers:
      return False

    volume_scan_node = None
    result = False

    for volume_identifier in volume_identifiers:
      volume_location = u'/{0:s}'.format(volume_identifier)
      volume_scan_node = scan_context.last_scan_node.GetSubNodeByLocation(
          volume_location)
      volume_path_spec = getattr(volume_scan_node, 'path_spec', None)

      file_system_scan_node = volume_scan_node.GetSubNodeByLocation(u'/')
      file_system_path_spec = getattr(file_system_scan_node, 'path_spec', None)
      file_system = resolver.Resolver.OpenFileSystem(file_system_path_spec)

      if file_system is None:
        continue

      path_resolver = windows_path_resolver.WindowsPathResolver(
          file_system, volume_path_spec)

      result = self._ScanFileSystem(path_resolver)
      if result:
        break

    if result:
      return volume_scan_node
github log2timeline / dfvfs / dfvfs / file_io / tar_file_io.py View on Github external
Args:
      path_spec (Optional[PathSpec]): path specification.
      mode (Optional[str]): file access mode.

    Raises:
      AccessError: if the access to open the file was denied.
      IOError: if the file-like object could not be opened.
      OSError: if the file-like object could not be opened.
      PathSpecError: if the path specification is incorrect.
      ValueError: if the path specification is invalid.
    """
    if not path_spec:
      raise ValueError('Missing path specification.')

    file_system = resolver.Resolver.OpenFileSystem(
        path_spec, resolver_context=self._resolver_context)

    file_entry = file_system.GetFileEntryByPathSpec(path_spec)
    if not file_entry:
      file_system.Close()
      raise IOError('Unable to retrieve file entry.')

    if not file_entry.IsFile():
      file_system.Close()
      raise IOError('Not a regular file.')

    self._file_system = file_system
    tar_file = self._file_system.GetTARFile()
    tar_info = file_entry.GetTARInfo()

    self._tar_ext_file = tar_file.extractfile(tar_info)
github log2timeline / dfvfs / examples / recursive_hasher2.py View on Github external
def CalculateHashes(self, base_path_specs, output_writer):
    """Recursive calculates hashes starting with the base path specification.

    Args:
      base_path_specs: a list of source path specification (instances
                       of dfvfs.PathSpec).
      output_writer: the output writer (instance of StdoutWriter).
    """
    for base_path_spec in base_path_specs:
      file_system = resolver.Resolver.OpenFileSystem(base_path_spec)
      file_entry = resolver.Resolver.OpenFileEntry(base_path_spec)
      if file_entry is None:
        logging.warning(
            u'Unable to open base path specification:\n{0:s}'.format(
                base_path_spec.comparable))
        continue

      self._CalculateHashesFileEntry(
          file_system, file_entry, u'', output_writer)
github log2timeline / plaso / plaso / frontend / preg.py View on Github external
resolver_context: Optional resolver context (instance of dfvfs.Context).
                        The default is None which will use the built in context
                        which is not multi process safe. Note that every thread
                        or process must have its own resolver context.

    Returns:
      A tuple of the file system (instance of dfvfs.FileSystem) and
      the mount point path specification (instance of path.PathSpec).

    Raises:
      RuntimeError: if source path specification is not set.
    """
    if not source_path_spec:
      raise RuntimeError(u'Missing source.')

    file_system = path_spec_resolver.Resolver.OpenFileSystem(
        source_path_spec, resolver_context=resolver_context)

    type_indicator = source_path_spec.type_indicator
    if path_spec_factory.Factory.IsSystemLevelTypeIndicator(type_indicator):
      mount_point = source_path_spec
    else:
      mount_point = source_path_spec.parent

    return file_system, mount_point
github log2timeline / dfvfs / dfvfs / resolver / mount_resolver_helper.py View on Github external
raise ValueError(u'Missing path specfication.')

    if path_spec.HasParent():
      raise errors.PathSpecError(u'Unsupported path specification with parent.')

    mount_point = getattr(path_spec, 'identifier', None)
    if not mount_point:
      raise errors.PathSpecError(
          u'Unsupported path specification without mount point identifier.')

    mount_path_spec = mount_manager.MountPointManager.GetMountPoint(mount_point)
    if not mount_path_spec:
      raise errors.MountPointError(
          u'No such mount point: {0:s}'.format(mount_point))

    return resolver.Resolver.OpenFileSystem(
        mount_path_spec, resolver_context=resolver_context)
github log2timeline / dfvfs / dfvfs / file_io / vshadow_file_io.py View on Github external
Raises:
      AccessError: if the access to open the file was denied.
      IOError: if the file-like object could not be opened.
      OSError: if the file-like object could not be opened.
      PathSpecError: if the path specification is incorrect.
      ValueError: if the path specification is invalid.
    """
    if not path_spec:
      raise ValueError('Missing path specification.')

    store_index = vshadow.VShadowPathSpecGetStoreIndex(path_spec)
    if store_index is None:
      raise errors.PathSpecError(
          'Unable to retrieve store index from path specification.')

    self._file_system = resolver.Resolver.OpenFileSystem(
        path_spec, resolver_context=self._resolver_context)
    vshadow_volume = self._file_system.GetVShadowVolume()

    if (store_index < 0 or
        store_index >= vshadow_volume.number_of_stores):
      raise errors.PathSpecError((
          'Unable to retrieve VSS store: {0:d} from path '
          'specification.').format(store_index))

    vshadow_store = vshadow_volume.get_store(store_index)
    if not vshadow_store.has_in_volume_data():
      raise IOError((
          'Unable to open VSS store: {0:d} without in-volume stored '
          'data.').format(store_index))

    self._vshadow_store = vshadow_store