pub fn read_nrg_version(fd: &mut File, file_size: u64) -> Result<u8, NrgError> {
    if file_size < 12 {
        // Input file too small
        return Err(NrgError::NrgFormat(
            "Input file is to small to be an NRG image".to_string()));
    }

    // In NRG v2, the main footer is on the last 12 bytes
    try!(fd.seek(SeekFrom::End(-12)));
    let chunk_id = try!(read_nrg_chunk_id(fd));
    if chunk_id == "NER5" {
        return Ok(2); // NRG v2
    }

    // In NRG v1, the main footer is on the last 8 bytes; since we just read 4
    // bytes after seeking 12 bytes before the end, the offset is right
    let chunk_id = try!(read_nrg_chunk_id(fd));
    if chunk_id == "NERO" {
        return Ok(1); // NRG v1
    }

    Err(NrgError::NrgFormat("Unknown format".to_string()))
}
/// Determines the NRG format of an open NRG image `fd` of file `file_size`.
///
/// `fd`'s offset at call-time doesn't matter, as this function will seek to
/// read the relevant data.
///
/// The offset is left after the main chunk ID, therefore the calling function
/// can read the first data chunk's offset (32 bits for NRG v1 or 64 bits for
/// NRG v2) directly without seeking.
Determines the NRG format of an open NRG image `fd` of file `file_size`.
`fd`'s offset at call-time doesn't matter, as this function will seek to
read the relevant data.

The offset is left after the main chunk ID, therefore the calling function
can read the first data chunk's offset (32 bits for NRG v1 or 64 bits for
NRG v2) directly without seeking.
Determines the NRG format of an open NRG image ` fd ` of file ` file_size ` . ` fd ` ' s offset at call - time doesn ' t matter as this function will seek to read the relevant data . The offset is left after the main chunk ID therefore the calling function can read the first data chunk ' s offset ( 32 bits for NRG v1 or 64 bits for NRG v2 ) directly without seeking .
pub fn read_nrg_version(fd: &mut File, file_size: u64) -> Result<u8, NrgError> {
    if file_size < 12 {
        // Input file too small
        return Err(NrgError::NrgFormat(
            "Input file is to small to be an NRG image".to_string()));
    }
    // In NRG v2, the main footer is on the last 12 bytes
    try!(fd.seek(SeekFrom::End(-12)));
    let chunk_id = try!(read_nrg_chunk_id(fd));
    if chunk_id == "NER5" {
        return Ok(2); // NRG v2
    }
    // In NRG v1, the main footer is on the last 8 bytes; since we just read 4
    // bytes after seeking 12 bytes before the end, the offset is right
    let chunk_id = try!(read_nrg_chunk_id(fd));
    if chunk_id == "NERO" {
        return Ok(1); // NRG v1
    }
    Err(NrgError::NrgFormat("Unknown format".to_string()))
}
pub fn read_nrg_version ( fd : & mut File , file_size : u64 ) -> Result < u8 , NrgError > { if file_size < 12 { // Input file too small return Err ( NrgError :: NrgFormat ( " " . to_string ( ) ) ) ; } // In NRG v2, the main footer is on the last 12 bytes try ! ( fd seek ( SeekFrom End ( 12 ) ) ) ; let chunk_id = try ! ( read_nrg_chunk_id ( fd ) ) ; if chunk_id == " " { return Ok ( 2 ) ; // NRG v2 } // In NRG v1, the main footer is on the last 8 bytes; since we just read 4 // bytes after seeking 12 bytes before the end, the offset is right let chunk_id = try ! ( read_nrg_chunk_id ( fd ) ) ; if chunk_id == " " { return Ok ( 1 ) ; // NRG v1 } Err ( NrgError :: NrgFormat ( " " . to_string ( ) ) ) }
Determines the NRG format of an open NRG image `fd` of file `file_size`.
Determines the NRG format of an open NRG image ` fd ` of file ` file_size ` .
fd
&mut File
file_size
u64
fd
&mut File
file_size
u64