fn find_data_on_disk(
        &mut self,
        volume: &Volume,
        start: &mut (u32, Cluster),
        desired_offset: u32,
    ) -> Result<(BlockIdx, usize, usize), Error<D::Error>> {
        let bytes_per_cluster = match &volume.volume_type {
            VolumeType::Fat16(fat) => fat.bytes_per_cluster(),
            VolumeType::Fat32(fat) => fat.bytes_per_cluster(),
        };
        // How many clusters forward do we need to go?
        let offset_from_cluster = desired_offset - start.0;
        let num_clusters = offset_from_cluster / bytes_per_cluster;
        for _ in 0..num_clusters {
            start.1 = match &volume.volume_type {
                VolumeType::Fat16(fat) => fat.next_cluster(self, start.1)?,
                VolumeType::Fat32(fat) => fat.next_cluster(self, start.1)?,
            };
            start.0 += bytes_per_cluster;
        }
        // How many blocks in are we?
        let offset_from_cluster = desired_offset - start.0;
        assert!(offset_from_cluster < bytes_per_cluster);
        let num_blocks = BlockCount(offset_from_cluster / Block::LEN_U32);
        let block_idx = match &volume.volume_type {
            VolumeType::Fat16(fat) => fat.cluster_to_block(start.1),
            VolumeType::Fat32(fat) => fat.cluster_to_block(start.1),
        } + num_blocks;
        let block_offset = (desired_offset % Block::LEN_U32) as usize;
        let available = Block::LEN - block_offset;
        Ok((block_idx, block_offset, available))
    }
/// This function turns `desired_offset` into an appropriate block to be
/// read. It either calculates this based on the start of the file, or
/// from the last cluster we read - whichever is better.
This function turns `desired_offset` into an appropriate block to be
read. It either calculates this based on the start of the file, or
from the last cluster we read - whichever is better.
This function turns ` desired_offset ` into an appropriate block to be read . It either calculates this based on the start of the file or from the last cluster we read - whichever is better .
fn find_data_on_disk(
        &mut self,
        volume: &Volume,
        start: &mut (u32, Cluster),
        desired_offset: u32,
    ) -> Result<(BlockIdx, usize, usize), Error<D::Error>> {
        let bytes_per_cluster = match &volume.volume_type {
            VolumeType::Fat16(fat) => fat.bytes_per_cluster(),
            VolumeType::Fat32(fat) => fat.bytes_per_cluster(),
        };
        // How many clusters forward do we need to go?
        let offset_from_cluster = desired_offset - start.0;
        let num_clusters = offset_from_cluster / bytes_per_cluster;
        for _ in 0..num_clusters {
            start.1 = match &volume.volume_type {
                VolumeType::Fat16(fat) => fat.next_cluster(self, start.1)?,
                VolumeType::Fat32(fat) => fat.next_cluster(self, start.1)?,
            };
            start.0 += bytes_per_cluster;
        }
        // How many blocks in are we?
        let offset_from_cluster = desired_offset - start.0;
        assert!(offset_from_cluster < bytes_per_cluster);
        let num_blocks = BlockCount(offset_from_cluster / Block::LEN_U32);
        let block_idx = match &volume.volume_type {
            VolumeType::Fat16(fat) => fat.cluster_to_block(start.1),
            VolumeType::Fat32(fat) => fat.cluster_to_block(start.1),
        } + num_blocks;
        let block_offset = (desired_offset % Block::LEN_U32) as usize;
        let available = Block::LEN - block_offset;
        Ok((block_idx, block_offset, available))
    }
fn find_data_on_disk ( & mut self , volume : & Volume , start : & mut ( u32 , Cluster ) , desired_offset : u32 , ) -> Result < ( BlockIdx , usize , usize ) , Error < D :: Error > > { let bytes_per_cluster = match & volume . volume_type { VolumeType :: Fat16 ( fat ) => fat . bytes_per_cluster ( ) , VolumeType :: Fat32 ( fat ) => fat . bytes_per_cluster ( ) , } ; // How many clusters forward do we need to go? let offset_from_cluster = desired_offset - start . 0 ; let num_clusters = offset_from_cluster / bytes_per_cluster ; for _ in 0 .. num_clusters { start . 1 = match & volume . volume_type { VolumeType :: Fat16 ( fat ) => fat . next_cluster ( self , start . 1 ) ? , VolumeType :: Fat32 ( fat ) => fat . next_cluster ( self , start . 1 ) ? , } ; start . 0 += bytes_per_cluster ; } // How many blocks in are we? let offset_from_cluster = desired_offset - start . 0 ; assert ! ( offset_from_cluster bytes_per_cluster ) ; let num_blocks = BlockCount ( offset_from_cluster / Block :: LEN_U32 ) ; let block_idx = match & volume . volume_type { VolumeType :: Fat16 ( fat ) => fat . cluster_to_block ( start . 1 ) , VolumeType :: Fat32 ( fat ) => fat . cluster_to_block ( start . 1 ) , } + num_blocks ; let block_offset = ( desired_offset % Block :: LEN_U32 ) as usize ; let available = Block :: LEN - block_offset ; Ok ( ( block_idx , block_offset , available ) ) }
This function turns `desired_offset` into an appropriate block to be
read.
This function turns ` desired_offset ` into an appropriate block to be read .
&mut self
volume
&Volume
start
&mut (u32, Cluster)
desired_offset
u32
&mut self
volume
&Volume
start
&mut (u32, Cluster)
desired_offset
u32