diff options
Diffstat (limited to 'src/recite/path.rs')
-rw-r--r-- | src/recite/path.rs | 42 |
1 files changed, 0 insertions, 42 deletions
diff --git a/src/recite/path.rs b/src/recite/path.rs deleted file mode 100644 index 28eb45b..0000000 --- a/src/recite/path.rs +++ /dev/null @@ -1,42 +0,0 @@ -use std::fs; -use std::path::Path; - -/// Refresh the shell's $PATH -/// -/// This function caches all valid paths within within the directories -/// specified. -/// -/// # Arguments -/// * `paths` - A reference to a vector that holds a list to the shell $PATHs -/// -/// # Returns -/// * `bins: Vec<String>` - A new cache of all valid file paths in $PATH -/// -/// # Examples -/// ``` -/// let path = vec!["/bin"]; -/// let path = path.into_iter().map(Path::new).collect(); -/// let mut bins = prefresh(&path); -/// ... -/// // A situation occurs where the $PATH needs to be refreshed -/// bins = prefresh(&path) -/// ``` -pub fn prefresh(path: &Vec<&Path>) -> Vec<String> { - let mut bins: Vec<String> = Vec::new(); - - for p in path { - let files = fs::read_dir(p).expect( - format!( - "dwvsh: error: unable to read the contents of {}", - p.display().to_string() - ) - .as_str(), - ); - - for file in files { - bins.push(file.unwrap().path().display().to_string()); - } - } - - bins -} |