pub struct Dir<'fs, IO: ReadWriteSeek, TP, OCC> { /* private fields */ }
Expand description
A FAT filesystem directory.
This struct is created by the open_dir
or create_dir
methods on Dir
.
The root directory is returned by the root_dir
method on FileSystem
.
Implementations§
Source§impl<'fs, IO: ReadWriteSeek, TP, OCC> Dir<'fs, IO, TP, OCC>
impl<'fs, IO: ReadWriteSeek, TP, OCC> Dir<'fs, IO, TP, OCC>
Source§impl<'fs, IO: ReadWriteSeek, TP: TimeProvider, OCC: OemCpConverter> Dir<'fs, IO, TP, OCC>
impl<'fs, IO: ReadWriteSeek, TP: TimeProvider, OCC: OemCpConverter> Dir<'fs, IO, TP, OCC>
Sourcepub fn set_created(&mut self, date_time: DateTime)
pub fn set_created(&mut self, date_time: DateTime)
Set modification datetime for this directory.
Sourcepub fn set_accessed(&mut self, date: Date)
pub fn set_accessed(&mut self, date: Date)
Set access date for this directory.
Sourcepub fn set_modified(&mut self, date_time: DateTime)
pub fn set_modified(&mut self, date_time: DateTime)
Set modification datetime for this directory.
Sourcepub fn open_dir(&self, path: &str) -> Result<Self>
pub fn open_dir(&self, path: &str) -> Result<Self>
Opens existing subdirectory.
path
is a ‘/’ separated directory path relative to self directory.
Sourcepub fn open_file(&self, path: &str) -> Result<File<'fs, IO, TP, OCC>>
pub fn open_file(&self, path: &str) -> Result<File<'fs, IO, TP, OCC>>
Opens existing file.
path
is a ‘/’ separated file path relative to self directory.
Sourcepub fn create_file(&self, path: &str) -> Result<File<'fs, IO, TP, OCC>>
pub fn create_file(&self, path: &str) -> Result<File<'fs, IO, TP, OCC>>
Creates new or opens existing file=.
path
is a ‘/’ separated file path relative to self directory.
File is never truncated when opening. It can be achieved by calling File::truncate
method after opening.
Sourcepub fn create_dir(&self, path: &str) -> Result<Self>
pub fn create_dir(&self, path: &str) -> Result<Self>
Creates new directory or opens existing.
path
is a ‘/’ separated path relative to self directory.
pub fn is_empty(&self) -> Result<bool>
Sourcepub fn remove(&self, path: &str) -> Result<()>
pub fn remove(&self, path: &str) -> Result<()>
Removes existing file or directory.
path
is a ‘/’ separated file path relative to self directory.
Make sure there is no reference to this file (no File instance) or filesystem corruption
can happen.
Sourcepub fn unlink_file(&self, file: &mut File<'_, IO, TP, OCC>) -> Result<()>
pub fn unlink_file(&self, file: &mut File<'_, IO, TP, OCC>) -> Result<()>
Unlink the given File from this directory.
Will cause filesystem corruption if the file is not actually in this directory, but continuing to use the file is legal. It will be completely removed from the filesystem once it is dropped.
Sourcepub fn unlink_dir(&self, dir: &mut Dir<'_, IO, TP, OCC>) -> Result<()>
pub fn unlink_dir(&self, dir: &mut Dir<'_, IO, TP, OCC>) -> Result<()>
Unlink the given Dir from this directory. Returns an error if the Dir is not empty.
Will cause filesystem corruption if the file is not actually in this directory. The directory’s clusters will be removed from the disk.
Sourcepub fn rename(
&self,
src_path: &str,
dst_dir: &Dir<'_, IO, TP, OCC>,
dst_path: &str,
) -> Result<()>
pub fn rename( &self, src_path: &str, dst_dir: &Dir<'_, IO, TP, OCC>, dst_path: &str, ) -> Result<()>
Renames or moves existing file or directory.
src_path
is a ‘/’ separated source file path relative to self directory.
dst_path
is a ‘/’ separated destination file path relative to dst_dir
.
dst_dir
can be set to self directory if rename operation without moving is needed.
Make sure there is no reference to this file (no File instance) or filesystem corruption
can happen.
Sourcepub fn rename_over_file(
&self,
src_path: &str,
dst_dir: &Dir<'_, IO, TP, OCC>,
dst_path: &str,
file: &mut File<'_, IO, TP, OCC>,
) -> Result<()>
pub fn rename_over_file( &self, src_path: &str, dst_dir: &Dir<'_, IO, TP, OCC>, dst_path: &str, file: &mut File<'_, IO, TP, OCC>, ) -> Result<()>
Same as rename, but supports renaming over an existing file.
Sourcepub fn rename_over_dir(
&self,
src_path: &str,
dst_dir: &Dir<'_, IO, TP, OCC>,
dst_path: &str,
dir: &mut Dir<'_, IO, TP, OCC>,
) -> Result<()>
pub fn rename_over_dir( &self, src_path: &str, dst_dir: &Dir<'_, IO, TP, OCC>, dst_path: &str, dir: &mut Dir<'_, IO, TP, OCC>, ) -> Result<()>
Same as rename but supports renaming over an existing directory (which must be empty).
Sourcepub fn flush_dir_entry(&mut self) -> Result<()>
pub fn flush_dir_entry(&mut self) -> Result<()>
Flushes the directory entry in the parent if not the root.