diff options
Diffstat (limited to 'dotup_cli/src/utils.rs')
| -rw-r--r-- | dotup_cli/src/utils.rs | 11 |
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 | ||
| 155 | pub 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 | } | ||
