1
0
mirror of https://github.com/jht5945/rust_util.git synced 2025-12-27 23:40:05 +08:00

add locate_file

This commit is contained in:
2020-05-04 20:54:16 +08:00
parent 7bfffc7bb6
commit 66d3540b65
2 changed files with 11 additions and 1 deletions

View File

@@ -13,6 +13,16 @@ use super::{
XResult,
};
pub fn locate_file(files: &[String]) -> Option<PathBuf> {
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<String> {
iff!(util_os::is_macos_or_linux(), env::var("HOME").ok(), None)
}