def _OpenPathSpec(self, pathspec: rdf_paths.PathSpec) -> client.File: if pathspec.HasField("stream_name"): stream_name = pathspec.stream_name else: stream_name = None if pathspec.HasField("inode"): return self.client.OpenByInode(pathspec.inode, stream_name) else: path = self._ToClientPath(pathspec.last.path) return self.client.Open(path, stream_name)
def _CheckHasImplementationType( self, pathspec: rdf_paths.PathSpec, implementation_type: rdf_paths.PathSpec.ImplementationType ) -> None: if implementation_type is None: self.assertFalse(pathspec.HasField("implementation_type")) else: self.assertEqual(pathspec.implementation_type, implementation_type) for i, component in enumerate(pathspec): if i > 0: self.assertFalse(component.HasField("implementation_type"))
def Open( cls, fd: Optional[vfs_base.VFSHandler], component: rdf_paths.PathSpec, handlers: Dict[Any, Type[vfs_base.VFSHandler]], pathspec: Optional[rdf_paths.PathSpec] = None, progress_callback: Optional[Callable[[], None]] = None ) -> Optional[vfs_base.VFSHandler]: # A Pathspec which starts with NTFS means we need to resolve the mount # point at runtime. if (fd is None and component.pathtype == rdf_paths.PathSpec.PathType.NTFS and pathspec is not None): # We are the top level handler. This means we need to check the system # mounts to work out the exact mount point and device we need to # open. We then modify the pathspec so we get nested in the raw # pathspec. raw_pathspec, corrected_path = client_utils.GetRawDevice( component.path) # Insert the raw device before the component in the pathspec and correct # the path component.path = corrected_path pathspec.Insert(0, component) pathspec.Insert(0, raw_pathspec) # Allow incoming pathspec to be given in the local system path # conventions. for component in pathspec: if component.path: component.path = client_utils.LocalPathToCanonicalPath( component.path) # We have not actually opened anything in this iteration, but modified the # pathspec. Next time we should be able to open it properly. return fd # If an inode is specified, just use it directly. # This is necessary so that component.path is ignored. elif component.HasField("inode"): return NTFSFile(fd, handlers, component, progress_callback=progress_callback) else: return super(NTFSFile, cls).Open(fd=fd, component=component, handlers=handlers, pathspec=pathspec, progress_callback=progress_callback)