pub struct Dir<'a, 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<'a, IO: ReadWriteSeek, TP, OCC> Dir<'a, IO, TP, OCC>
impl<'a, IO: ReadWriteSeek, TP, OCC> Dir<'a, IO, TP, OCC>
Source§impl<'a, IO: ReadWriteSeek, TP: TimeProvider, OCC: OemCpConverter> Dir<'a, IO, TP, OCC>
impl<'a, IO: ReadWriteSeek, TP: TimeProvider, OCC: OemCpConverter> Dir<'a, IO, TP, OCC>
Sourcepub fn as_file(&self) -> Option<&File<'a, IO, TP, OCC>>
pub fn as_file(&self) -> Option<&File<'a, IO, TP, OCC>>
Returns the underlying file object if the directory stream is not a root directory in FAT12 & FAT16.
Sourcepub fn open_dir(&self, path: &str) -> Result<Self, Error<IO::Error>>
pub fn open_dir(&self, path: &str) -> Result<Self, Error<IO::Error>>
Opens existing subdirectory.
path is a ‘/’ separated directory path relative to self directory.
§Errors
Errors that can be returned:
Error::NotFoundwill be returned ifpathdoes not point to any existing directory entry.Error::InvalidInputwill be returned ifpathpoints to a file that is not a directory.Error::Iowill be returned if the underlying storage object returned an I/O error.
Sourcepub fn open_file(
&self,
path: &str,
) -> Result<File<'a, IO, TP, OCC>, Error<IO::Error>>
pub fn open_file( &self, path: &str, ) -> Result<File<'a, IO, TP, OCC>, Error<IO::Error>>
Opens existing file.
path is a ‘/’ separated file path relative to self directory.
§Errors
Errors that can be returned:
Error::NotFoundwill be returned ifpathpoints to a non-existing directory entry.Error::InvalidInputwill be returned ifpathpoints to a file that is a directory.Error::Iowill be returned if the underlying storage object returned an I/O error.
Sourcepub fn create_file(
&self,
path: &str,
) -> Result<File<'a, IO, TP, OCC>, Error<IO::Error>>
pub fn create_file( &self, path: &str, ) -> Result<File<'a, IO, TP, OCC>, Error<IO::Error>>
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.
§Errors
Errors that can be returned:
Error::InvalidInputwill be returned ifpathpoints to an existing file that is a directory.Error::InvalidFileNameLengthwill be returned if the file name is empty or if it is too long.Error::UnsupportedFileNameCharacterwill be returned if the file name contains an invalid character.Error::NotEnoughSpacewill be returned if there is not enough free space to create a new file.Error::Iowill be returned if the underlying storage object returned an I/O error.
Sourcepub fn create_dir(&self, path: &str) -> Result<Self, Error<IO::Error>>
pub fn create_dir(&self, path: &str) -> Result<Self, Error<IO::Error>>
Creates new directory or opens existing.
path is a ‘/’ separated path relative to self directory.
§Errors
Errors that can be returned:
Error::InvalidInputwill be returned ifpathpoints to an existing file that is not a directory.Error::InvalidFileNameLengthwill be returned if the file name is empty or if it is too long.Error::UnsupportedFileNameCharacterwill be returned if the file name contains an invalid character.Error::NotEnoughSpacewill be returned if there is not enough free space to create a new directory.Error::Iowill be returned if the underlying storage object returned an I/O error.
Sourcepub fn remove(&self, path: &str) -> Result<(), Error<IO::Error>>
pub fn remove(&self, path: &str) -> Result<(), Error<IO::Error>>
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.
§Errors
Errors that can be returned:
Error::NotFoundwill be returned ifpathpoints to a non-existing directory entry.Error::InvalidInputwill be returned ifpathpoints to a file that is not a directory.Error::DirectoryIsNotEmptywill be returned if the specified directory is not empty.Error::Iowill be returned if the underlying storage object returned an I/O error.
Sourcepub fn rename(
&self,
src_path: &str,
dst_dir: &Dir<'_, IO, TP, OCC>,
dst_path: &str,
) -> Result<(), Error<IO::Error>>
pub fn rename( &self, src_path: &str, dst_dir: &Dir<'_, IO, TP, OCC>, dst_path: &str, ) -> Result<(), Error<IO::Error>>
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.
§Errors
Errors that can be returned:
Error::NotFoundwill be returned ifsrc_pathpoints to a non-existing directory entry or ifdst_pathstripped from the last component does not point to an existing directory.Error::AlreadyExistswill be returned ifdst_pathpoints to an existing directory entry.Error::Iowill be returned if the underlying storage object returned an I/O error.