pub struct Fat12 { /* private fields */ }Expand description
FAT12 table implementation.
FAT12 uses 12-bit entries packed into 3 bytes for every 2 clusters.
Implementations§
Source§impl Fat12
impl Fat12
Sourcepub fn new(start: usize, size: usize, count: usize, max_cluster: u16) -> Self
pub fn new(start: usize, size: usize, count: usize, max_cluster: u16) -> Self
Creates a FAT12 table descriptor.
Sourcepub fn max_cluster(&self) -> u16
pub fn max_cluster(&self) -> u16
Get the maximum cluster number.
Sourcepub fn next_cluster<T: Read + Seek>(
&self,
reader: &mut T,
cluster: usize,
) -> Result<Option<u32>>
pub fn next_cluster<T: Read + Seek>( &self, reader: &mut T, cluster: usize, ) -> Result<Option<u32>>
Returns the next cluster in a chain, or None at end-of-chain.
Sourcepub fn write_clus<T: Read + Write + Seek>(
&self,
rw: &mut T,
cluster: usize,
value: u16,
) -> Result<()>
pub fn write_clus<T: Read + Write + Seek>( &self, rw: &mut T, cluster: usize, value: u16, ) -> Result<()>
Write a cluster entry to all FAT table copies
Sourcepub fn allocate_cluster<T: Read + Write + Seek>(
&self,
rw: &mut T,
hint: u16,
) -> Result<u16>
pub fn allocate_cluster<T: Read + Write + Seek>( &self, rw: &mut T, hint: u16, ) -> Result<u16>
Allocate a single cluster, returns the allocated cluster number.
Sourcepub fn allocate_chain<T: Read + Write + Seek>(
&self,
rw: &mut T,
count: usize,
hint: u16,
) -> Result<u16>
pub fn allocate_chain<T: Read + Write + Seek>( &self, rw: &mut T, count: usize, hint: u16, ) -> Result<u16>
Allocate a linked chain of count clusters, returning the first cluster.
Each cluster is allocated from a rolling hint (near the previous one) and
linked to its successor; the last is marked end-of-chain. Mirrors
Fat32::allocate_chain. On partial failure the already-allocated
clusters are not rolled back (matching the FAT32 behavior).
Sourcepub fn extend_chain<T: Read + Write + Seek>(
&self,
rw: &mut T,
last: u16,
count: usize,
hint: u16,
) -> Result<u16>
pub fn extend_chain<T: Read + Write + Seek>( &self, rw: &mut T, last: u16, count: usize, hint: u16, ) -> Result<u16>
Extend the chain whose current last cluster is last by count
clusters, returning the first newly allocated cluster. If count is 0,
no clusters are allocated and last is returned unchanged. Mirrors
Fat32::extend_chain.
Sourcepub fn free_chain<T: Read + Write + Seek>(
&self,
rw: &mut T,
start: u16,
) -> Result<u32>
pub fn free_chain<T: Read + Write + Seek>( &self, rw: &mut T, start: u16, ) -> Result<u32>
Free a cluster chain starting at start, returns count of freed clusters.
Sourcepub fn truncate_chain<T: Read + Write + Seek>(
&self,
rw: &mut T,
cluster: u16,
) -> Result<u32>
pub fn truncate_chain<T: Read + Write + Seek>( &self, rw: &mut T, cluster: u16, ) -> Result<u32>
Truncate a cluster chain after the specified cluster.
The specified cluster becomes the end of chain (marked with end-of-chain marker). All clusters following it are freed.
Returns the number of clusters freed.