aboutsummaryrefslogtreecommitdiff
path: root/dotup_cli/src/utils.rs
diff options
context:
space:
mode:
authordiogo464 <[email protected]>2021-12-24 21:01:11 +0000
committerdiogo464 <[email protected]>2021-12-24 21:01:11 +0000
commitffcb43df8f39a55be468cf4bdfecd72dd026d940 (patch)
tree252bb880ebb268a88c3c043f21ff4c923d905451 /dotup_cli/src/utils.rs
parent793b726b1393210bbfc934bb8236066ae52ebdab (diff)
initial implementation of status command
closes #1
Diffstat (limited to 'dotup_cli/src/utils.rs')
-rw-r--r--dotup_cli/src/utils.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/dotup_cli/src/utils.rs b/dotup_cli/src/utils.rs
index a5c7647..be9f3a9 100644
--- a/dotup_cli/src/utils.rs
+++ b/dotup_cli/src/utils.rs
@@ -149,3 +149,14 @@ pub fn collect_files_in_dir(dir: impl Into<PathBuf>) -> anyhow::Result<Vec<PathB
149 149
150 Ok(paths) 150 Ok(paths)
151} 151}
152
153/// Collects the result of std::fs::read_dir into two vecs
154/// The first one contains all the directories and the second one all the files
155pub fn collect_read_dir_split(
156 dir: impl AsRef<Path>,
157) -> anyhow::Result<(Vec<PathBuf>, Vec<PathBuf>)> {
158 Ok(std::fs::read_dir(dir)?
159 .filter_map(|e| e.ok())
160 .map(|e| e.path())
161 .partition(|p| p.is_dir()))
162}