1use std::path::{Path, PathBuf};
2
3pub struct Options {
4 pub(crate) path: PathBuf,
5 pub(crate) existing_file_behaviour: FileExistsBehaviour,
6}
7
8#[derive(PartialEq)]
9pub enum FileExistsBehaviour {
10 Halt,
12
13 Update,
15
16 Overwrite,
18}
19
20impl Options {
21 pub fn new(path: &str, overwrite: FileExistsBehaviour) -> Options {
24 Options {
25 path: Path::new(path).into(),
26 existing_file_behaviour: overwrite,
27 }
28 }
29}
30
31impl FileExistsBehaviour {
32 pub(crate) fn create_new(&self) -> bool {
33 match self {
34 FileExistsBehaviour::Halt => true,
35 FileExistsBehaviour::Update => false,
36 FileExistsBehaviour::Overwrite => false,
37 }
38 }
39}