Remove compilation warnings

This commit is contained in:
Romain Garbage 2022-09-08 18:36:16 +02:00
parent 83519d184f
commit 9417dc7992
No known key found for this signature in database
GPG key ID: 9DFBAECAE17DF2EE
3 changed files with 2 additions and 17 deletions

View file

@ -81,7 +81,7 @@ impl Crc {
result.to_le_bytes().to_vec()
}
pub fn compute_checksum(&mut self, data: &[u8]) -> Vec<u8> {
pub fn _compute_checksum(&mut self, data: &[u8]) -> Vec<u8> {
let mut checksum = Vec::new();
let size = data.len();
let mut offset = 0;

View file

@ -103,11 +103,6 @@ impl Input {
Ok(())
}
/// Extract the content of the img files to disk
pub fn extract(&mut self) -> Result<(), Error> {
unimplemented!()
}
/// Extract the checksum file to the disk
pub fn extract_checksum(&mut self) -> Result<(), Error> {
for part in self.img_parts.clone() {
@ -185,27 +180,18 @@ impl Input {
const CAPACITY: usize = 100 * 1024 * 1024; // Set temp buffer capacity to 100MB
let mut buffer = vec![0; CAPACITY]; // allocate an empty buffer until the specified capacity
let mut bytes_copied = 0;
//eprintln!("seeking the right offset");
self.data.seek(SeekFrom::Start(offset))?;
//let mut read_buffer = self.data.take(part.header.filesize());
// Buffered copy to the output file
while bytes_copied < size {
let remaining_bytes = size - bytes_copied;
//eprintln!("remaining_bytes = {remaining_bytes}");
// shrink buffer to the right size
buffer.truncate(std::cmp::min(CAPACITY, remaining_bytes));
//eprintln!("buffer len: {}", buffer.len());
//eprintln!("buffer capacity: {}", buffer.capacity());
//eprintln!("filling buffer...");
let bytes_read = self.data.read(&mut buffer)?;
//eprintln!("read {bytes_read} bytes");
if bytes_read == 0 {
return Err(Error::new("Read 0 bytes".into()));
}
w.write_all(&buffer)?;
//eprintln!("Done copying");
bytes_copied += bytes_read;
//eprintln!("bytes_copied = {bytes_copied}");
}
Ok(())
}

View file

@ -2,7 +2,6 @@ use std::process::ExitCode;
use clap::{CommandFactory, Parser};
use extractor::Extractor;
use local_error::Error;
mod crc;
mod extractor;