pub struct VirtualFileSystem { /* private fields */ }
Expand description
A reference to an virtual file system.
Implementations§
Source§impl VirtualFileSystem
impl VirtualFileSystem
Sourcepub fn try_new<P>(root: P) -> Result<VirtualFileSystem, Error>
pub fn try_new<P>(root: P) -> Result<VirtualFileSystem, Error>
Creates new VirtualFileSystem
.
root
- base directory for VFS.
A root
path must exists; else return value will be io::Error
.
It will be normalized.
Sourcepub fn absolute<P>(&self, path: P) -> Option<PathBuf>
pub fn absolute<P>(&self, path: P) -> Option<PathBuf>
Convert relative path
to absolute.
If path
is absolute and starts with current root
, then return it, else return None
.
If path
is relative, then append it to the end of the current root
and return joined path.
Sourcepub fn relative<P>(&self, path: P) -> Option<PathBuf>
pub fn relative<P>(&self, path: P) -> Option<PathBuf>
Convert absolute path
to relative.
If path
is relative, then normalize it and return.
If path
is equal to root
, then return .
(current).
If root
equals to /foo/bar
and path
equals to /foo/bar/more
, then return more
.
Sourcepub fn exists<P>(&self, path: P) -> bool
pub fn exists<P>(&self, path: P) -> bool
Returns true if the path points at an existing entity.
Sourcepub fn chroot<P>(&mut self, new_root: P) -> bool
pub fn chroot<P>(&mut self, new_root: P) -> bool
Change current root
.
A new_root
path may be absolute or relative.
Return true if root
was change.
Sourcepub fn create_dir<P>(&self, path: P) -> Result<(), Error>
pub fn create_dir<P>(&self, path: P) -> Result<(), Error>
Creates a new, empty directory at the provided path.
Sourcepub fn create_dir_all<P>(&self, path: P) -> Result<(), Error>
pub fn create_dir_all<P>(&self, path: P) -> Result<(), Error>
Recursively create a directory and all of its parent components if they are missing.
Sourcepub fn remove_dir<P>(&self, path: P) -> Result<(), Error>
pub fn remove_dir<P>(&self, path: P) -> Result<(), Error>
Removes an existing, empty directory.
Sourcepub fn remove_dir_all<P>(&self, path: P) -> Result<(), Error>
pub fn remove_dir_all<P>(&self, path: P) -> Result<(), Error>
Removes a directory at this path, after removing all its contents. Use carefully!