ChRootFileSystem

Struct ChRootFileSystem 

Source
pub struct ChRootFileSystem { /* private fields */ }
Expand description

Changes the apparent root directory of the underlaying virtual filesystem like chroot on unix.

Implementations§

Source§

impl ChRootFileSystem

Source

pub fn new<P>(path: P, fs: Box<dyn VirtualFileSystem>) -> Self
where P: Into<PathBuf>,

Creates a new ChRoot file system

use forensic_rs::prelude::*;
use std::path::Path;
let chrfs = ChRootFileSystem::new(Path::new("C:\\"), Box::new(StdVirtualFS::new()));
let exists_c_windows = chrfs.exists(Path::new("Windows"));

Trait Implementations§

Source§

impl VirtualFileSystem for ChRootFileSystem

Source§

fn read_to_string(&mut self, path: &Path) -> ForensicResult<String>

Read the entire contents of a file into a string.
Source§

fn is_live(&self) -> bool

Check if the VirtualFileSystem is an abstraction over the real filesystem and not a virtual (like a ZIP file).
Source§

fn read_all(&mut self, path: &Path) -> ForensicResult<Vec<u8>>

Read the entire contents of a file into a bytes vector.
Source§

fn read( &mut self, path: &Path, pos: u64, buf: &mut [u8], ) -> ForensicResult<usize>

Read part of the content of a file into a bytes vector.
Source§

fn metadata(&mut self, path: &Path) -> ForensicResult<VMetadata>

Get the metadata of a file/dir
Source§

fn read_dir(&mut self, path: &Path) -> ForensicResult<Vec<VDirEntry>>

Lists the contents of a Directory
Source§

fn from_file( &self, _file: Box<dyn VirtualFile>, ) -> ForensicResult<Box<dyn VirtualFileSystem>>

Initializes a virtual filesystem from a file. Ex: a Zip FS from a file
Source§

fn from_fs( &self, fs: Box<dyn VirtualFileSystem>, ) -> ForensicResult<Box<dyn VirtualFileSystem>>

Initializes a virtual filesystem from a filesyste. Ex: a remapping of windows routes to Linux routes.
Source§

fn open(&mut self, path: &Path) -> ForensicResult<Box<dyn VirtualFile>>

Open a file
Source§

fn duplicate(&self) -> Box<dyn VirtualFileSystem>

Allows duplicating the existing file system
Source§

fn exists(&self, path: &Path) -> bool

Check if a file exists

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.