1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
//! Duplicate Destroyer Library
//!
//! This library provides functionality to find duplicate files and folders.
//!
//! To search for duplicates in a set of directories, call `get_duplicates` function. The function
//! goes recursively through all the directories in its input and finds all duplicate files and
//! directories. It then returns the topmost directories and files for which there exists at least
//! one duplicate.
//!
//! # Example usage
//! Suppose we have directory structure:
//! ```bash
//! tests/fixtures/
//! ├── A
//! │ ├── a.txt
//! │ └── b
//! │ ├── alpha.txt
//! │ └── beta.txt
//! ├── B
//! │ └── A
//! │ ├── a.txt
//! │ └── b
//! │ ├── alpha.txt
//! │ └── beta.txt
//! └── C
//! ├── a.txt
//! ├── b
//! │ ├── alpha.txt
//! │ └── beta.txt
//! └── diff.txt
//!
//! ```
//! The `get_duplicates` function would then return these directories as duplicates
//! {"tests/fixtures/A", "tests/fixtures/B/A"}:
//!
//! ```
//! # use std::collections::HashSet;
//! # use std::ffi::OsString;
//! use duplicate_destroyer::*;
//!
//! // Create DuDe configuration
//! let mut config: Config = Default::default();
//! config.set_minimum_size(0); // Use non-default minimum size (see Config structure for details)
//!
//! // Create vector of paths to search for duplicates
//! let input_dirs = vec![OsString::from("tests/fixtures")];
//!
//! // Get duplicates
//! let duplicates = duplicate_destroyer::get_duplicates(input_dirs, &config).unwrap();
//!
//! let expected_paths = [OsString::from("tests/fixtures/A"),
//! OsString::from("tests/fixtures/B/A")];
//! let expected_output = DuplicateObject::new(8235, HashSet::from(expected_paths));
//! assert_eq!(duplicates[0], expected_output)
//! ```
pub use HashAlgorithm;
pub use Config;
pub use DuplicateObject;
pub use *;
use *;
use OsString;
/// Find the largest duplicate directories or files
///
/// Goes recursively through each dir in `directories` and finds all duplicated files and
/// directories. Ouputs the topmost directory or file that is duplicated within the dirs in
/// `directories`.
///
/// # Arguments:
/// * `directories` - vector of paths that will be searched for duplicates
/// * `config` - configuration of duplicate destroyer. See [`Config`](crate::Config) struct