49 lines
1.6 KiB
Rust
49 lines
1.6 KiB
Rust
use std::path::PathBuf;
|
|
use std::sync::LazyLock;
|
|
|
|
use clap::{ArgAction, Parser};
|
|
|
|
pub static CONFIG: LazyLock<Args> = LazyLock::new(|| Args::parse());
|
|
|
|
#[derive(Parser, Debug, Clone)]
|
|
pub struct Args {
|
|
/// Path to source file or block device
|
|
#[arg(short, long, value_hint = clap::ValueHint::DirPath)]
|
|
pub input: PathBuf,
|
|
|
|
/// Path to output file. Defaults to {input}.iso
|
|
#[arg(short, long, value_hint = clap::ValueHint::DirPath)]
|
|
pub output: Option<PathBuf>,
|
|
|
|
/// Path to rescue map. Defaults to {input}.map
|
|
#[arg(short, long, value_hint = clap::ValueHint::DirPath)]
|
|
pub map: Option<PathBuf>,
|
|
|
|
/// Max number of consecutive sectors to test as a group
|
|
#[arg(short, long, default_value_t = crate::FB_CLUSTER_LEN)]
|
|
pub cluster_length: usize,
|
|
|
|
/// Number of brute force read passes
|
|
#[arg(short, long, default_value_t = 2)]
|
|
pub brute_passes: usize,
|
|
|
|
/// Sector size
|
|
#[arg(short, long, default_value_t = crate::FB_SECTOR_SIZE)]
|
|
pub sector_size: usize,
|
|
|
|
// !!! ArgAction behaviour is backwards !!!
|
|
// ArgAction::SetFalse by default evaluates to true,
|
|
// ArgAction::SetTrue by default evaluates to false.
|
|
//
|
|
/// Upon encountering a read error, reopen the source file before continuing.
|
|
#[arg(short, long, action = ArgAction::SetTrue)]
|
|
pub reopen_on_error: bool,
|
|
|
|
/// Use O_DIRECT to bypass kernel buffer when reading.
|
|
//
|
|
// BSD seems to support O_DIRECT, but MacOS for certain does not.
|
|
#[cfg(all(unix, not(target_os = "macos")))]
|
|
#[arg(short, long = "direct", action = ArgAction::SetFalse)]
|
|
pub direct_io: bool,
|
|
}
|