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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/// Options for archiving files in the host filesystem to a litebox.
///
/// This is used with [`Filesystem::archive_with`].
///
/// [`Filesystem::archive_with`]: crate::Filesystem::archive_with
#[derive(Debug, Clone)]
pub struct ArchiveOptions {
follow: bool,
children: bool,
recursive: bool,
metadata: bool,
}
impl Default for ArchiveOptions {
fn default() -> Self {
Self::new()
}
}
impl ArchiveOptions {
/// Create a new [`ArchiveOptions`] default settings.
pub fn new() -> Self {
Self {
follow: false,
children: false,
recursive: true,
metadata: true,
}
}
/// Follow symbolic links.
///
/// If this is `true`, the file the symbolic links points to will be archived instead of the
/// symbolic link itself.
///
/// The default is `false`.
pub fn follow_symlinks(mut self, follow: bool) -> Self {
self.follow = follow;
self
}
/// Archive the children of the source directory instead of the source directory itself.
///
/// This puts the children of the source directory into the given destination directory.
///
/// The default is `false`.
pub fn children(mut self, children: bool) -> Self {
self.children = children;
self
}
/// Archive the source directory recursively.
///
/// This has no effect if the source is a regular file.
///
/// The default is `true`.
pub fn recursive(mut self, recursive: bool) -> Self {
self.recursive = recursive;
self
}
/// Preserve file metadata when copying files into the archive.
///
/// The default is `true`.
pub fn preserve_metadata(mut self, preserve: bool) -> Self {
self.metadata = preserve;
self
}
}
#[cfg(all(feature = "fs", target_family = "unix"))]
impl ArchiveOptions {
pub(crate) fn should_follow_symlinks(&self) -> bool {
self.follow
}
pub(crate) fn should_archive_children(&self) -> bool {
self.children
}
pub(crate) fn is_recursive(&self) -> bool {
self.recursive
}
pub(crate) fn should_preserve_metadata(&self) -> bool {
self.metadata
}
}
/// Options for extracting files in a litebox to host the filesystem.
///
/// This is used with [`Filesystem::extract_with`].
///
/// [`Filesystem::extract_with`]: crate::Filesystem::extract_with
#[derive(Debug, Clone)]
pub struct ExtractOptions {
children: bool,
recursive: bool,
}
impl Default for ExtractOptions {
fn default() -> Self {
Self::new()
}
}
impl ExtractOptions {
/// Create a new [`ExtractOptions`] with default settings.
pub fn new() -> Self {
Self {
children: false,
recursive: true,
}
}
/// Extract the children of the source directory instead of the source directory itself.
///
/// This puts the children of the source directory into the given destination directory.
///
/// The default is `false`.
pub fn children(mut self, children: bool) -> Self {
self.children = children;
self
}
/// Extract the source directory recursively.
///
/// This has no effect if the source is a regular file.
///
/// The default is `true`.
pub fn recursive(mut self, recursive: bool) -> Self {
self.recursive = recursive;
self
}
}
#[cfg(all(feature = "fs", target_family = "unix"))]
impl ExtractOptions {
pub(crate) fn should_extract_children(&self) -> bool {
self.children
}
pub(crate) fn is_recursive(&self) -> bool {
self.recursive
}
}