Struct fatfs::FileSystem
source · pub struct FileSystem<T: ReadWriteSeek> { /* private fields */ }
Expand description
A FAT filesystem object.
FileSystem
struct is representing a state of a mounted FAT volume.
Implementations§
source§impl<T: ReadWriteSeek> FileSystem<T>
impl<T: ReadWriteSeek> FileSystem<T>
sourcepub fn new(disk: T, options: FsOptions) -> Result<Self>
pub fn new(disk: T, options: FsOptions) -> Result<Self>
Creates a new filesystem object instance.
Supplied disk
parameter cannot be seeked. If there is a need to read a fragment of disk
image (e.g. partition) library user should wrap the file struct in a struct limiting
access to partition bytes only e.g. fscommon::StreamSlice
.
Note: creating multiple filesystem objects with one underlying device/disk image can cause a filesystem corruption.
sourcepub fn fat_type(&self) -> FatType
pub fn fat_type(&self) -> FatType
Returns a type of File Allocation Table (FAT) used by this filesystem.
sourcepub fn volume_label(&self) -> String
pub fn volume_label(&self) -> String
Returns a volume label from BPB in the Boot Sector as String
.
Non-ASCII characters are replaced by the replacement character (U+FFFD).
Note: This function returns label stored in the BPB structure. Use read_volume_label_from_root_dir
to read
label from the root directory.
sourcepub fn volume_label_as_bytes(&self) -> &[u8] ⓘ
pub fn volume_label_as_bytes(&self) -> &[u8] ⓘ
Returns a volume label from BPB in the Boot Sector as byte array slice.
Label is encoded in the OEM codepage.
Note: This function returns label stored in the BPB structure. Use read_volume_label_from_root_dir_as_bytes
to read label from the root directory.
sourcepub fn read_volume_label_from_root_dir(&self) -> Result<Option<String>>
pub fn read_volume_label_from_root_dir(&self) -> Result<Option<String>>
Returns a volume label from root directory as String
.
It finds file with VOLUME_ID
attribute and returns its short name.
sourcepub fn read_volume_label_from_root_dir_as_bytes(
&self,
) -> Result<Option<[u8; 11]>>
pub fn read_volume_label_from_root_dir_as_bytes( &self, ) -> Result<Option<[u8; 11]>>
Returns a volume label from root directory as byte array.
Label is encoded in the OEM codepage.
It finds file with VOLUME_ID
attribute and returns its short name.
sourcepub fn root_dir<'b>(&'b self) -> Dir<'b, T>
pub fn root_dir<'b>(&'b self) -> Dir<'b, T>
Returns a root directory object allowing for futher penetration of a filesystem structure.
pub fn cluster_size(&self) -> u32
sourcepub fn read_status_flags(&self) -> Result<FsStatusFlags>
pub fn read_status_flags(&self) -> Result<FsStatusFlags>
Returns status flags for this volume.
sourcepub fn stats(&self) -> Result<FileSystemStats>
pub fn stats(&self) -> Result<FileSystemStats>
Returns filesystem statistics like number of total and free clusters.
For FAT32 volumes number of free clusters from FSInfo sector is returned (may be incorrect). For other FAT variants number is computed on the first call to this method and cached for later use.
Trait Implementations§
source§impl<T: ReadWriteSeek> Drop for FileSystem<T>
impl<T: ReadWriteSeek> Drop for FileSystem<T>
Drop
implementation tries to unmount the filesystem when dropping.