Esempio n. 1
0
    def _Open(self, mode='rb'):
        """Opens the file system defined by path specification.

    Args:
      mode (Optional[str]): file access mode. The default is 'rb'
          read-only binary.

    Raises:
      AccessError: if the access to open the file was denied.
      IOError: if the file system could not be opened.
      PathSpecError: if the path specification is incorrect.
      ValueError: if the path specification is invalid.
    """
        if not self._path_spec.HasParent():
            raise errors.PathSpecError(
                'Unsupported path specification without parent.')

        resolver.Resolver.key_chain.ExtractCredentialsFromPathSpec(
            self._path_spec)

        fvde_volume = pyfvde.volume()
        file_object = resolver.Resolver.OpenFileObject(
            self._path_spec.parent, resolver_context=self._resolver_context)

        fvde.FVDEVolumeOpen(fvde_volume, self._path_spec, file_object,
                            resolver.Resolver.key_chain)

        self._fvde_volume = fvde_volume
        self._file_object = file_object
Esempio n. 2
0
    def _OpenFileObject(self, path_spec):
        """Opens the file-like object defined by path specification.

    Args:
      path_spec (PathSpec): path specification.

    Returns:
      A file-like object.

    Raises:
      PathSpecError: if the path specification is incorrect.
    """
        if not path_spec.HasParent():
            raise errors.PathSpecError(
                u'Unsupported path specification without parent.')

        file_object = resolver.Resolver.OpenFileObject(
            path_spec.parent, resolver_context=self._resolver_context)
        fvde_volume = pyfvde.volume()
        fvde.FVDEVolumeOpen(fvde_volume, path_spec, file_object,
                            resolver.Resolver.key_chain)
        return fvde_volume