pub fn have_same_contents<P: AsRef<Path>>(source: P, target: P) -> Result<bool> {
    let source = source.as_ref();
    let target = target.as_ref();

    let mut source_file = File::open(source)?;
    let mut target_file = File::open(target)?;

    const BUFFER_SIZE : usize = 512;

    let mut source_buffer = [0u8;BUFFER_SIZE];
    let mut target_buffer = [0u8;BUFFER_SIZE];

    loop {
        let source_read = source_file.read(&mut source_buffer)?;
        let target_read = target_file.read(&mut target_buffer)?;

        if source_read == 0 && target_read == 0 {
            break;
        }

        if source_read != target_read {
            return Ok(false)
        }

        if &source_buffer[..] != &target_buffer[..] {
            return Ok(false)
        }
    }

    Ok(true)
}
/// Verify if two files have the same contents.
Verify if two files have the same contents.
Verify if two files have the same contents .
pub fn have_same_contents<P: AsRef<Path>>(source: P, target: P) -> Result<bool> {
    let source = source.as_ref();
    let target = target.as_ref();
    let mut source_file = File::open(source)?;
    let mut target_file = File::open(target)?;
    const BUFFER_SIZE : usize = 512;
    let mut source_buffer = [0u8;BUFFER_SIZE];
    let mut target_buffer = [0u8;BUFFER_SIZE];
    loop {
        let source_read = source_file.read(&mut source_buffer)?;
        let target_read = target_file.read(&mut target_buffer)?;
        if source_read == 0 && target_read == 0 {
            break;
        }
        if source_read != target_read {
            return Ok(false)
        }
        if &source_buffer[..] != &target_buffer[..] {
            return Ok(false)
        }
    }
    Ok(true)
}
pub fn have_same_contents < P : AsRef < Path > > ( source : P , target : P ) -> Result < bool > { let source = source . as_ref ( ) ; let target = target . as_ref ( ) ; let mut source_file = File :: open ( source ) ? ; let mut target_file = File :: open ( target ) ? ; const BUFFER_SIZE : usize = 512 ; let mut source_buffer = [ 0u8 ; BUFFER_SIZE ] ; let mut target_buffer = [ 0u8 ; BUFFER_SIZE ] ; loop { let source_read = source_file . read ( & mut source_buffer ) ? ; let target_read = target_file . read ( & mut target_buffer ) ? ; if source_read == 0 && target_read == 0 { break ; } if source_read != target_read { return Ok ( false ) } if & source_buffer [ .. ] != & target_buffer [ .. ] { return Ok ( false ) } } Ok ( true ) }
Verify if two files have the same contents.
Verify if two files have the same contents .
source
P
target
P