1use glob::glob;
6use nc::Errno;
7use std::path::PathBuf;
8use std::result::Result;
9
10use crate::core::env::expand_env;
11
12pub struct RmOptions {
13 pub recursive: bool,
15
16 pub preserve_root: bool,
18
19 pub one_file_system: bool,
22
23 pub empty_dir: bool,
25
26 pub expand_env: bool,
28
29 pub use_glob: bool,
31}
32
33impl RmOptions {
34 pub fn new() -> Self {
35 RmOptions::default()
36 }
37}
38
39impl Default for RmOptions {
40 fn default() -> Self {
41 RmOptions {
42 recursive: false,
43 preserve_root: true,
44 one_file_system: false,
45 empty_dir: false,
46 expand_env: true,
47 use_glob: true,
48 }
49 }
50}
51
52pub fn rm<T: AsRef<str>>(path: T, options: &RmOptions) -> Result<(), Errno> {
53 let path = if options.expand_env {
54 expand_env(path)
55 } else {
56 path.as_ref().to_string()
57 };
58
59 let _path_list: Vec<PathBuf> = if options.use_glob {
60 glob(&path).unwrap().filter_map(Result::ok).collect()
61 } else {
62 vec![PathBuf::from(path)]
63 };
64
65 return Ok(());
66}
67
68fn do_rm() {}