fn copy(
        &mut self,
        stream_in: &mut File,
        stream_out: &mut File,
        data: &EntryData,
    ) -> Result<(), Error> {
        assert!(self.buf.len() % 4 == 0); // needed for alignment

        stream_in.seek(SeekFrom::Start(data.offset as u64))?;

        let mut magic = data.magic;
        let mut size = data.size; // remaining bytes to read
        loop {
            let limit = self.buf.len().min(size as usize);
            let count = read_until_full(stream_in, &mut self.buf[..limit])?;
            if count == 0 { return Ok(()) }
            let buf = &mut self.buf[..count];

            let (prefix, middle, suffix) = unsafe { buf.align_to_mut::<u32>() };
            assert!(prefix.len() == 0); // assume buf is aligned

            for i in 0..middle.len() {
                let mut w = u32::from_le(middle[i]);
                w ^= advance_magic(&mut magic);
                middle[i] = w.to_le();
            }

            for i in 0..suffix.len() {
                suffix[i] ^= (magic >> (i * 8)) as u8;
            }

            size -= count as u32;
            stream_out.write_all(buf)?;
        }
    }
/// Encrypts/decrypts file data from stream_in to stream_out.
Encrypts/decrypts file data from stream_in to stream_out.
Encrypts / decrypts file data from stream_in to stream_out .
fn copy(
        &mut self,
        stream_in: &mut File,
        stream_out: &mut File,
        data: &EntryData,
    ) -> Result<(), Error> {
        assert!(self.buf.len() % 4 == 0); // needed for alignment
        stream_in.seek(SeekFrom::Start(data.offset as u64))?;
        let mut magic = data.magic;
        let mut size = data.size; // remaining bytes to read
        loop {
            let limit = self.buf.len().min(size as usize);
            let count = read_until_full(stream_in, &mut self.buf[..limit])?;
            if count == 0 { return Ok(()) }
            let buf = &mut self.buf[..count];
            let (prefix, middle, suffix) = unsafe { buf.align_to_mut::<u32>() };
            assert!(prefix.len() == 0); // assume buf is aligned
            for i in 0..middle.len() {
                let mut w = u32::from_le(middle[i]);
                w ^= advance_magic(&mut magic);
                middle[i] = w.to_le();
            }
            for i in 0..suffix.len() {
                suffix[i] ^= (magic >> (i * 8)) as u8;
            }
            size -= count as u32;
            stream_out.write_all(buf)?;
        }
    }
fn copy ( & mut self , stream_in : & mut File , stream_out : & mut File , data : & EntryData , ) -> Result < ( ) , Error > { assert ! ( self buf len ( ) 4 0 ) ; // needed for alignment stream_in . seek ( SeekFrom :: Start ( data . offset as u64 ) ) ? ; let mut magic = data . magic ; let mut size = data . size ; // remaining bytes to read loop { let limit = self . buf . len ( ) . min ( size as usize ) ; let count = read_until_full ( stream_in , & mut self . buf [ .. limit ] ) ? ; if count == 0 { return Ok ( ( ) ) } let buf = & mut self . buf [ .. count ] ; let ( prefix , middle , suffix ) = unsafe { buf . align_to_mut :: < u32 > ( ) } ; assert ! ( prefix len ( ) 0 ) ; // assume buf is aligned for i in 0 .. middle . len ( ) { let mut w = u32 :: from_le ( middle [ i ] ) ; w ^= advance_magic ( & mut magic ) ; middle [ i ] = w . to_le ( ) ; } for i in 0 .. suffix . len ( ) { suffix [ i ] ^= ( magic >> ( i * 8 ) ) as u8 ; } size -= count as u32 ; stream_out . write_all ( buf ) ? ; } }
Encrypts/decrypts file data from stream_in to stream_out.
Encrypts / decrypts file data from stream_in to stream_out .
&mut self
stream_in
&mut File
stream_out
&mut File
data
&EntryData
&mut self
stream_in
&mut File
stream_out
&mut File
data
&EntryData