diff --git a/Cargo.toml b/Cargo.toml index c5d4640..de703b7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rust_util" -version = "0.2.3" +version = "0.2.4" authors = ["Hatter Jiang "] edition = "2018" description = "Hatter's Rust Util" diff --git a/src/util_file.rs b/src/util_file.rs index ea4cbd8..47bce8f 100644 --- a/src/util_file.rs +++ b/src/util_file.rs @@ -13,6 +13,16 @@ use super::{ XResult, }; +pub fn locate_file(files: &[String]) -> Option { + for f in files { + match PathBuf::from(&resolve_file_path(f)) { + pb if pb.is_file() => return Some(pb), + _ => (), + } + } + None +} + pub fn get_home_str() -> Option { iff!(util_os::is_macos_or_linux(), env::var("HOME").ok(), None) }