FileSystem

Struct FileSystem 

Source
pub struct FileSystem<S>
where S: Read + Seek,
{ /* private fields */ }
Expand description

An API to process a FAT filesystem

Implementations§

Source§

impl<S> FileSystem<S>
where S: Read + Seek,

Getter functions

Source

pub fn fat_type(&self) -> FATType

What is the FATType of the filesystem

Source§

impl<S> FileSystem<S>
where S: Read + Seek,

Setter functions

Source

pub fn show_hidden(&self, show: bool)

Whether or not to list hidden files

Off by default

Source

pub fn show_system(&self, show: bool)

Whether or not to list system files

Off by default

Source§

impl<S> FileSystem<S>
where S: Read + Seek,

Constructors for a FileSystem

Source

pub fn new(storage: S, options: FSOptions) -> FSResult<Self, S::Error>

Create a FileSystem from a storage object

Fails if the storage is way too small to support a FAT filesystem. For most use cases, that shouldn’t be an issue, you can just call .unwrap()

Source§

impl<S> FileSystem<S>
where S: Read + Seek,

Public Read-related functions

Source

pub fn read_dir<P: AsRef<Path>>( &self, path: P, ) -> FSResult<ReadDir<'_, S>, S::Error>

Read all the entries of a directory (Path) into ReadDir

Fails if path doesn’t represent a directory, or if that directory doesn’t exist

Source

pub fn get_ro_file<P: AsRef<Path>>( &self, path: P, ) -> FSResult<ROFile<'_, S>, S::Error>

Get a corresponding ROFile object from a Path

Fails if path doesn’t represent a file, or if that file doesn’t exist

Source§

impl<S> FileSystem<S>
where S: Read + Write + Seek,

Write-related functions

Source

pub fn create_file<P: AsRef<Path>>( &self, path: P, ) -> FSResult<RWFile<'_, S>, S::Error>

Create a new RWFile and return its handle

Source

pub fn create_dir<P: AsRef<Path>>(&self, path: P) -> FSResult<(), S::Error>

Create a new directory

Source

pub fn rename<P: AsRef<Path>, Q: AsRef<Path>>( &self, from: P, to: Q, ) -> FSResult<(), S::Error>

Rename a file or directory to a new name

Source

pub fn remove_file<P: AsRef<Path>>(&self, path: P) -> FSResult<(), S::Error>

Remove a RWFile from the filesystem

This is an alias to self.get_rw_file(path)?.remove()?

Source

pub fn remove_file_unchecked<P: AsRef<Path>>( &self, path: P, ) -> FSResult<(), S::Error>

Remove a file from the filesystem, even if it is read-only

USE WITH EXTREME CAUTION!

Source

pub fn remove_empty_dir<P: AsRef<Path>>( &self, path: P, ) -> FSResult<(), S::Error>

Remove an empty directory from the filesystem

Errors if the path provided points to the root directory

Source

pub fn remove_dir_all<P: AsRef<Path>>(&self, path: P) -> FSResult<(), S::Error>

Removes a directory at this path, after removing all its contents.

Use with caution!

This will fail if there is at least 1 (one) read-only file in this directory or in any subdirectory. To avoid this behavior, use remove_dir_all_unchecked()

Source

pub fn remove_dir_all_unchecked<P: AsRef<Path>>( &self, path: P, ) -> FSResult<(), S::Error>

Like remove_dir_all(), but also removes read-only files.

USE WITH EXTREME CAUTION!

Source

pub fn check_for_readonly_files<P: AsRef<Path>>( &self, path: P, ) -> FSResult<bool, S::Error>

Check path recursively to see if there are any read-only files in it

If successful, the bool returned indicates whether or not at least 1 (one) read-only file has been found

Source

pub fn get_rw_file<P: AsRef<Path>>( &self, path: P, ) -> FSResult<RWFile<'_, S>, S::Error>

Get a corresponding RWFile object from a Path

Fails if path doesn’t represent a file, or if that file doesn’t exist

Source

pub fn unmount(&self) -> FSResult<(), S::Error>

Sync any pending changes back to the storage medium and drop

Use this to catch any IO errors that might be rejected silently while Dropping

Trait Implementations§

Source§

impl<S> Debug for FileSystem<S>
where S: Read + Seek + Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<S> Drop for FileSystem<S>
where S: Read + Seek,

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<S> !Freeze for FileSystem<S>

§

impl<S> !RefUnwindSafe for FileSystem<S>

§

impl<S> !Send for FileSystem<S>

§

impl<S> !Sync for FileSystem<S>

§

impl<S> Unpin for FileSystem<S>
where S: Unpin,

§

impl<S> !UnwindSafe for FileSystem<S>

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.