Struct uefi::fs::FileSystem
source · pub struct FileSystem<'a>(/* private fields */);
alloc
only.Expand description
High-level file-system abstraction for UEFI volumes with an API that is
close to std::fs
. It acts as convenient accessor around the
SimpleFileSystemProtocol
.
Implementations§
source§impl<'a> FileSystem<'a>
impl<'a> FileSystem<'a>
sourcepub fn new(proto: ScopedProtocol<'a, SimpleFileSystemProtocol>) -> Self
pub fn new(proto: ScopedProtocol<'a, SimpleFileSystemProtocol>) -> Self
Constructor.
sourcepub fn try_exists(&mut self, path: impl AsRef<Path>) -> FileSystemResult<bool>
pub fn try_exists(&mut self, path: impl AsRef<Path>) -> FileSystemResult<bool>
Returns Ok(true)
if the path points at an existing file.
If the file does not exist, Ok(false)
is returned. If it cannot be
determined whether the file exists or not, an error is returned.
sourcepub fn copy(
&mut self,
src_path: impl AsRef<Path>,
dest_path: impl AsRef<Path>
) -> FileSystemResult<()>
pub fn copy( &mut self, src_path: impl AsRef<Path>, dest_path: impl AsRef<Path> ) -> FileSystemResult<()>
Copies the contents of one file to another. Creates the destination file if it doesn’t exist and overwrites any content, if it exists.
sourcepub fn create_dir(&mut self, path: impl AsRef<Path>) -> FileSystemResult<()>
pub fn create_dir(&mut self, path: impl AsRef<Path>) -> FileSystemResult<()>
Creates a new, empty directory at the provided path
sourcepub fn create_dir_all(&mut self, path: impl AsRef<Path>) -> FileSystemResult<()>
pub fn create_dir_all(&mut self, path: impl AsRef<Path>) -> FileSystemResult<()>
Recursively create a directory and all of its parent components if they are missing.
sourcepub fn metadata(
&mut self,
path: impl AsRef<Path>
) -> FileSystemResult<Box<UefiFileInfo>>
pub fn metadata( &mut self, path: impl AsRef<Path> ) -> FileSystemResult<Box<UefiFileInfo>>
Given a path, query the file system to get information about a file,
directory, etc. Returns UefiFileInfo
.
sourcepub fn read(&mut self, path: impl AsRef<Path>) -> FileSystemResult<Vec<u8>>
pub fn read(&mut self, path: impl AsRef<Path>) -> FileSystemResult<Vec<u8>>
Read the entire contents of a file into a bytes vector.
sourcepub fn read_dir(
&mut self,
path: impl AsRef<Path>
) -> FileSystemResult<UefiDirectoryIter>
pub fn read_dir( &mut self, path: impl AsRef<Path> ) -> FileSystemResult<UefiDirectoryIter>
Returns an iterator over the entries within a directory.
sourcepub fn read_to_string(
&mut self,
path: impl AsRef<Path>
) -> FileSystemResult<String>
pub fn read_to_string( &mut self, path: impl AsRef<Path> ) -> FileSystemResult<String>
Read the entire contents of a file into a Rust string.
sourcepub fn remove_dir(&mut self, path: impl AsRef<Path>) -> FileSystemResult<()>
pub fn remove_dir(&mut self, path: impl AsRef<Path>) -> FileSystemResult<()>
Removes an empty directory.
sourcepub fn remove_dir_all(&mut self, path: impl AsRef<Path>) -> FileSystemResult<()>
pub fn remove_dir_all(&mut self, path: impl AsRef<Path>) -> FileSystemResult<()>
Removes a directory at this path, after removing all its contents. Use carefully!
sourcepub fn remove_file(&mut self, path: impl AsRef<Path>) -> FileSystemResult<()>
pub fn remove_file(&mut self, path: impl AsRef<Path>) -> FileSystemResult<()>
Removes a file from the filesystem.