pub(crate) fn next_cluster<D, T>(
        &self,
        controller: &Controller<D, T>,
        cluster: Cluster,
    ) -> Result<Cluster, Error<D::Error>>
    where
        D: BlockDevice,
        T: TimeSource,
    {
        let mut blocks = [Block::new()];
        let fat_offset = cluster.0 * 2;
        let this_fat_block_num = self.lba_start + self.fat_start.offset_bytes(fat_offset);
        let this_fat_ent_offset = (fat_offset % Block::LEN_U32) as usize;
        controller
            .block_device
            .read(&mut blocks, this_fat_block_num, "next_cluster")
            .map_err(Error::DeviceError)?;
        let fat_entry =
            LittleEndian::read_u16(&blocks[0][this_fat_ent_offset..=this_fat_ent_offset + 1]);
        match fat_entry {
            0xFFF7 => {
                // Bad cluster
                Err(Error::BadCluster)
            }
            0xFFF8..=0xFFFF => {
                // There is no next cluster
                Err(Error::EndOfFile)
            }
            f => {
                // Seems legit
                Ok(Cluster(u32::from(f)))
            }
        }
    }
/// Look in the FAT to see which cluster comes next.
Look in the FAT to see which cluster comes next.
Look in the FAT to see which cluster comes next .
pub(crate) fn next_cluster<D, T>(
        &self,
        controller: &Controller<D, T>,
        cluster: Cluster,
    ) -> Result<Cluster, Error<D::Error>>
    where
        D: BlockDevice,
        T: TimeSource,
    {
        let mut blocks = [Block::new()];
        let fat_offset = cluster.0 * 2;
        let this_fat_block_num = self.lba_start + self.fat_start.offset_bytes(fat_offset);
        let this_fat_ent_offset = (fat_offset % Block::LEN_U32) as usize;
        controller
            .block_device
            .read(&mut blocks, this_fat_block_num, "next_cluster")
            .map_err(Error::DeviceError)?;
        let fat_entry =
            LittleEndian::read_u16(&blocks[0][this_fat_ent_offset..=this_fat_ent_offset + 1]);
        match fat_entry {
            0xFFF7 => {
                // Bad cluster
                Err(Error::BadCluster)
            }
            0xFFF8..=0xFFFF => {
                // There is no next cluster
                Err(Error::EndOfFile)
            }
            f => {
                // Seems legit
                Ok(Cluster(u32::from(f)))
            }
        }
    }
pub ( crate ) fn next_cluster < D , T > ( & self , controller : & Controller < D , T > , cluster : Cluster , ) -> Result < Cluster , Error < D :: Error > > where D : BlockDevice , T : TimeSource , { let mut blocks = [ Block :: new ( ) ] ; let fat_offset = cluster . 0 * 2 ; let this_fat_block_num = self . lba_start + self . fat_start . offset_bytes ( fat_offset ) ; let this_fat_ent_offset = ( fat_offset % Block :: LEN_U32 ) as usize ; controller . block_device . read ( & mut blocks , this_fat_block_num , " " ) . map_err ( Error :: DeviceError ) ? ; let fat_entry = LittleEndian :: read_u16 ( & blocks [ 0 ] [ this_fat_ent_offset ..= this_fat_ent_offset + 1 ] ) ; match fat_entry { 0xFFF7 => { // Bad cluster Err ( Error :: BadCluster ) } 0xFFF8 ..= 0xFFFF => { // There is no next cluster Err ( Error :: EndOfFile ) } f => { // Seems legit Ok ( Cluster ( u32 :: from ( f ) ) ) } } }
Look in the FAT to see which cluster comes next.
Look in the FAT to see which cluster comes next .
&self
controller
&Controller<D, T>
cluster
Cluster
&self
controller
&Controller<D, T>
cluster
Cluster