pub fn read(
        &mut self,
        volume: &Volume,
        file: &mut File,
        buffer: &mut [u8],
    ) -> Result<usize, Error<D::Error>> {
        // Calculate which file block the current offset lies within
        // While there is more to read, read the block and copy in to the buffer.
        // If we need to find the next cluster, walk the FAT.
        let mut space = buffer.len();
        let mut read = 0;
        while space > 0 && !file.eof() {
            let (block_idx, block_offset, block_avail) =
                self.find_data_on_disk(volume, &mut file.current_cluster, file.current_offset)?;
            let mut blocks = [Block::new()];
            self.block_device
                .read(&mut blocks, block_idx, "read")
                .map_err(Error::DeviceError)?;
            let block = &blocks[0];
            let to_copy = block_avail.min(space).min(file.left() as usize);
            assert!(to_copy != 0);
            buffer[read..read + to_copy]
                .copy_from_slice(&block[block_offset..block_offset + to_copy]);
            read += to_copy;
            space -= to_copy;
            file.seek_from_current(to_copy as i32).unwrap();
        }
        Ok(read)
    }
/// Read from an open file.
Read from an open file.
Read from an open file .
pub fn read(
        &mut self,
        volume: &Volume,
        file: &mut File,
        buffer: &mut [u8],
    ) -> Result<usize, Error<D::Error>> {
        // Calculate which file block the current offset lies within
        // While there is more to read, read the block and copy in to the buffer.
        // If we need to find the next cluster, walk the FAT.
        let mut space = buffer.len();
        let mut read = 0;
        while space > 0 && !file.eof() {
            let (block_idx, block_offset, block_avail) =
                self.find_data_on_disk(volume, &mut file.current_cluster, file.current_offset)?;
            let mut blocks = [Block::new()];
            self.block_device
                .read(&mut blocks, block_idx, "read")
                .map_err(Error::DeviceError)?;
            let block = &blocks[0];
            let to_copy = block_avail.min(space).min(file.left() as usize);
            assert!(to_copy != 0);
            buffer[read..read + to_copy]
                .copy_from_slice(&block[block_offset..block_offset + to_copy]);
            read += to_copy;
            space -= to_copy;
            file.seek_from_current(to_copy as i32).unwrap();
        }
        Ok(read)
    }
pub fn read ( & mut self , volume : & Volume , file : & mut File , buffer : & mut [ u8 ] , ) -> Result < usize , Error < D :: Error > > { // Calculate which file block the current offset lies within // While there is more to read, read the block and copy in to the buffer. // If we need to find the next cluster, walk the FAT. let mut space = buffer . len ( ) ; let mut read = 0 ; while space > 0 && ! file . eof ( ) { let ( block_idx , block_offset , block_avail ) = self . find_data_on_disk ( volume , & mut file . current_cluster , file . current_offset ) ? ; let mut blocks = [ Block :: new ( ) ] ; self . block_device . read ( & mut blocks , block_idx , " " ) . map_err ( Error :: DeviceError ) ? ; let block = & blocks [ 0 ] ; let to_copy = block_avail . min ( space ) . min ( file . left ( ) as usize ) ; assert ! ( to_copy 0 ) ; buffer [ read .. read + to_copy ] . copy_from_slice ( & block [ block_offset .. block_offset + to_copy ] ) ; read += to_copy ; space -= to_copy ; file . seek_from_current ( to_copy as i32 ) . unwrap ( ) ; } Ok ( read ) }
Read from an open file.
Read from an open file .
&mut self
volume
&Volume
file
&mut File
buffer
&mut [u8]
&mut self
volume
&Volume
file
&mut File
buffer
&mut [u8]