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:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user