pub struct FileSystem<D, const SIZE: usize, const N: usize>where
D: BlockDevice<SIZE>,{ /* private fields */ }Implementations§
Source§impl<D, const SIZE: usize, const N: usize> FileSystem<D, SIZE, N>where
D: BlockDevice<SIZE>,
impl<D, const SIZE: usize, const N: usize> FileSystem<D, SIZE, N>where
D: BlockDevice<SIZE>,
pub fn new(io: D) -> Self
pub fn into_inner(self) -> D
Sourcepub fn set_time_provider(&mut self, time_provider: fn() -> Timestamp)
pub fn set_time_provider(&mut self, time_provider: fn() -> Timestamp)
Sets the time provider for file and directory timestamps
Sourcepub fn mount(&mut self) -> ExFatResult<(), D, SIZE>
pub fn mount(&mut self) -> ExFatResult<(), D, SIZE>
Calling this is optional as the file system will be automatically mounted upon first use if it is not already mounted Reads the boot sector using the block device and initializes the file system returning an instance of it
pub fn open( &mut self, path: &str, options: OpenOptions, ) -> ExFatResult<File, D, SIZE>
Sourcepub fn exists(&mut self, path: &str) -> ExFatResult<bool, D, SIZE>
pub fn exists(&mut self, path: &str) -> ExFatResult<bool, D, SIZE>
Returns true if the file or directory exists
Symbolic link following is not supported
Sourcepub fn read_dir(
&mut self,
path: &str,
) -> ExFatResult<DirectoryIterator<SIZE>, D, SIZE>
pub fn read_dir( &mut self, path: &str, ) -> ExFatResult<DirectoryIterator<SIZE>, D, SIZE>
Returns an iterator over the entries in a directory
Supports nested paths
Sourcepub fn remove_file(&mut self, path: &str) -> ExFatResult<(), D, SIZE>
pub fn remove_file(&mut self, path: &str) -> ExFatResult<(), D, SIZE>
Deletes a file
Returns an error if the file does not exist or something else failed
Sourcepub fn create_directory(&mut self, path: &str) -> ExFatResult<(), D, SIZE>
pub fn create_directory(&mut self, path: &str) -> ExFatResult<(), D, SIZE>
Creates a directory recursively
The dir path can be nested
Sourcepub fn copy(
&mut self,
from_path: &str,
to_path: &str,
) -> ExFatResult<(), D, SIZE>
pub fn copy( &mut self, from_path: &str, to_path: &str, ) -> ExFatResult<(), D, SIZE>
Copies a file from one file to another
If directories in the to_path do not exist they will be created File attributes will also be copied but timestamps will be new
Sourcepub fn rename(
&mut self,
from_path: &str,
to_path: &str,
) -> ExFatResult<(), D, SIZE>
pub fn rename( &mut self, from_path: &str, to_path: &str, ) -> ExFatResult<(), D, SIZE>
Rename a file or folder (also know as move)
The from_path is the old file or directory path (including all sub directories) The to_path is the new file or directory path (including all sub directories) If the file or directory changes parent directories then this is considered to be a file move, otherwise a rename If the to_path contains directories that don’t yet exist they will be created.
Sourcepub fn remove_dir(&mut self, path: &str) -> ExFatResult<(), D, SIZE>
pub fn remove_dir(&mut self, path: &str) -> ExFatResult<(), D, SIZE>
Removes an empty directory
Will return an error if the directory does not exist or is not empty
Sourcepub fn write(
&mut self,
path: &str,
contents: impl AsRef<[u8]>,
) -> ExFatResult<(), D, SIZE>
pub fn write( &mut self, path: &str, contents: impl AsRef<[u8]>, ) -> ExFatResult<(), D, SIZE>
Writes the entire contents to a file.
The file will be overwritten if it already exists. This function will create any directories in the path that do not already exist. Relative paths are not supported.
Sourcepub fn unmount(self) -> D
pub fn unmount(self) -> D
unmounts the file system and returns the device back to the user. IMPORTANT: it is up to the caller to ensure that all open files have been closed. it is not necessary to unmount the file system for consistency for example if you need to reboot However, a reboot SHOULD close all open files beforehand