diff options
author | rabite <rabite@posteo.de> | 2019-02-26 10:17:51 +0100 |
---|---|---|
committer | rabite <rabite@posteo.de> | 2019-02-26 10:17:51 +0100 |
commit | 4c1e75c0580e763b66047423cdcd51d18b954e7f (patch) | |
tree | eed51ea8cd46683a2b2645479ee0b84694bf99a4 /src/window.rs | |
parent | d0029949ea1d137525564ce3eb5dae3f18ea011e (diff) |
fix warnings
Diffstat (limited to 'src/window.rs')
-rw-r--r-- | src/window.rs | 52 |
1 files changed, 1 insertions, 51 deletions
diff --git a/src/window.rs b/src/window.rs index fc08b47..f974208 100644 --- a/src/window.rs +++ b/src/window.rs @@ -2,7 +2,7 @@ use std::io::{stdin, stdout, Stdout, Write}; use std::sync::{Arc, Mutex}; use std::sync::mpsc::{Sender, Receiver, channel}; -use termion::event::{Event, Key}; +use termion::event::Event; use termion::input::TermRead; use termion::screen::AlternateScreen; @@ -206,53 +206,3 @@ pub fn show_status(status: &str) { pub fn minibuffer(query: &str) -> HResult<String> { MINIBUFFER.lock()?.query(query) } - -pub fn find_bins(comp_name: &str) -> Vec<String> { - let paths = std::env::var_os("PATH").unwrap() - .to_string_lossy() - .split(":") - .map(|s| s.to_string()) - .collect::<Vec<String>>(); - - paths.iter().map(|path| { - std::fs::read_dir(path).unwrap().flat_map(|file| { - let file = file.unwrap(); - let name = file.file_name().into_string().unwrap(); - if name.starts_with(comp_name) { - Some(name) - } else { - None - } - }).collect::<Vec<String>>() - }).flatten().collect::<Vec<String>>() -} - -pub fn find_files(mut comp_name: String) -> Vec<String> { - let mut path = std::path::PathBuf::from(&comp_name); - - let dir = if comp_name.starts_with("/") { - comp_name = path.file_name().unwrap().to_string_lossy().to_string(); - path.pop(); - path.to_string_lossy().to_string() - } else { - std::env::current_dir().unwrap().to_string_lossy().to_string() - }; - - let reader = std::fs::read_dir(dir.clone()); - if reader.is_err() { return vec![] } - let reader = reader.unwrap(); - - reader.flat_map(|file| { - let file = file.unwrap(); - let name = file.file_name().into_string().unwrap(); - if name.starts_with(&comp_name) { - if file.file_type().unwrap().is_dir() { - Some(format!("{}/{}/", &dir, name)) - } else { - Some(format!("/{}/", name)) - } - } else { - None - } - }).collect::<Vec<String>>() -} |