You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
90 lines
1.8 KiB
90 lines
1.8 KiB
use super::*;
|
|
use lazy_static::lazy_static;
|
|
|
|
#[cfg(feature="threads")]
|
|
use std::num::NonZeroUsize;
|
|
|
|
#[derive(Debug, Clone)]
|
|
pub enum RecursionMode
|
|
{
|
|
None,
|
|
All,
|
|
N(usize),
|
|
}
|
|
|
|
#[derive(Debug, Clone)]
|
|
pub enum OperationMode
|
|
{
|
|
Print,
|
|
Delete,
|
|
}
|
|
|
|
|
|
#[derive(Debug, Clone)]
|
|
pub struct Mode
|
|
{
|
|
pub error_mode: error::Mode,
|
|
pub recursion_mode: RecursionMode,
|
|
pub operation_mode: OperationMode,
|
|
pub logging_mode: log::Mode,
|
|
}
|
|
|
|
impl Default for Mode
|
|
{
|
|
fn default() -> Self
|
|
{
|
|
Self {
|
|
error_mode: error::Mode::Cancel,
|
|
recursion_mode: RecursionMode::None,
|
|
operation_mode: OperationMode::Print,
|
|
logging_mode: log::Mode::Warn,
|
|
}
|
|
}
|
|
}
|
|
|
|
lazy_static! {
|
|
pub static ref DEFAULT_HASHNAME: &'static str = {
|
|
let string = expand_path(DEFAULT_HASHNAME_STRING);
|
|
Box::leak(string.into_boxed_str())
|
|
};
|
|
}
|
|
const DEFAULT_HASHNAME_STRING: &'static str = "~/.rmdupe";
|
|
|
|
/// Expand path for shell
|
|
fn expand_path(path: impl AsRef<str>) -> String
|
|
{
|
|
shellexpand::tilde(path.as_ref()).to_string()
|
|
}
|
|
|
|
/// Default max threads, `None` for unlimited.
|
|
#[cfg(feature="threads")]
|
|
pub const MAX_THREADS: Option<NonZeroUsize> = Some(unsafe{NonZeroUsize::new_unchecked(10)});
|
|
|
|
#[derive(Debug)]
|
|
pub struct Config
|
|
{
|
|
/// Paths to dupde-check
|
|
pub paths: Vec<String>,
|
|
/// operation mode
|
|
pub mode: Mode,
|
|
/// Save hashes to
|
|
pub save: Vec<String>,
|
|
/// Load hashes from
|
|
pub load: Vec<String>,
|
|
/// Max number of threads to spawn
|
|
#[cfg(feature="threads")]
|
|
pub max_threads: Option<NonZeroUsize>, //TODO: Implement
|
|
}
|
|
|
|
#[derive(Debug)]
|
|
pub struct Rebase
|
|
{
|
|
/// Load from here
|
|
pub load: Vec<String>,
|
|
/// Rebase to here
|
|
pub save: Vec<String>,
|
|
/// Max number of threads to spawn
|
|
#[cfg(feature="threads")]
|
|
pub max_threads: Option<NonZeroUsize>, //TODO: Implement
|
|
}
|