Tons of cleanup. More useless git notices.
This commit is contained in:
70
src/main.rs
70
src/main.rs
@@ -1,79 +1,19 @@
|
||||
mod cli;
|
||||
mod io;
|
||||
mod mapping;
|
||||
mod path;
|
||||
mod recovery;
|
||||
|
||||
use std::fs::{File, OpenOptions};
|
||||
|
||||
use cli::Args;
|
||||
use mapping::prelude::*;
|
||||
use recovery::Recover;
|
||||
|
||||
use anyhow::{self, Context};
|
||||
use clap::Parser;
|
||||
use anyhow;
|
||||
|
||||
const FB_SECTOR_SIZE: u16 = 2048;
|
||||
const FB_PAD_VALUE: u8 = 0;
|
||||
const FB_SECTOR_SIZE: usize = 2048;
|
||||
const FB_NULL_VALUE: u8 = 0;
|
||||
|
||||
fn main() -> anyhow::Result<()> {
|
||||
let config = Args::parse();
|
||||
|
||||
let mut input: File = {
|
||||
let input_path = &config.input.as_path();
|
||||
|
||||
OpenOptions::new()
|
||||
.read(true)
|
||||
.open(&input_path)
|
||||
.with_context(|| format!("Failed to open input file: {}", input_path.display()))?
|
||||
};
|
||||
|
||||
let output: File = {
|
||||
// Keep this clean, make a short-lived binding.
|
||||
let path = crate::io::get_path(&config.output, &config.input, "iso")
|
||||
.context("Failed to generate output path.")?;
|
||||
|
||||
OpenOptions::new()
|
||||
.read(true)
|
||||
.write(true)
|
||||
.create(true)
|
||||
.open(&path)
|
||||
.with_context(|| format!("Failed to open/create output file at: {}", path.display()))?
|
||||
};
|
||||
|
||||
let map: MapFile = {
|
||||
let path = crate::io::get_path(&config.map, &config.input, "map")
|
||||
.context("Failed to generate map path.")?;
|
||||
|
||||
MapFile::try_from(
|
||||
OpenOptions::new()
|
||||
.read(true)
|
||||
.write(true)
|
||||
.create(true)
|
||||
.open(&path)
|
||||
.with_context(|| {
|
||||
format!("Failed to open/create mapping file at: {}", path.display())
|
||||
})?,
|
||||
)
|
||||
.unwrap_or(MapFile::new(config.sector_size))
|
||||
};
|
||||
|
||||
let mut recover_tool = Recover::new(&config, &mut input, output, map)?;
|
||||
|
||||
let mut recover_tool = Recover::new()?;
|
||||
recover_tool.run()?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[allow(unused)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
// Test for get_path
|
||||
// Need to determine how to package files to test with, or at least
|
||||
// how to test with PathBuf present.
|
||||
// Test must also check unwrapping of file name, not just generation.
|
||||
|
||||
// Test for get_stream_length
|
||||
// Need to determine how to test with Seek-able objects.
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user