mirror of
https://github.com/jht5945/rust_util.git
synced 2025-12-27 15:40:03 +08:00
add locate_file
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "rust_util"
|
name = "rust_util"
|
||||||
version = "0.2.3"
|
version = "0.2.4"
|
||||||
authors = ["Hatter Jiang <jht5945@gmail.com>"]
|
authors = ["Hatter Jiang <jht5945@gmail.com>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
description = "Hatter's Rust Util"
|
description = "Hatter's Rust Util"
|
||||||
|
|||||||
@@ -13,6 +13,16 @@ use super::{
|
|||||||
XResult,
|
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> {
|
pub fn get_home_str() -> Option<String> {
|
||||||
iff!(util_os::is_macos_or_linux(), env::var("HOME").ok(), None)
|
iff!(util_os::is_macos_or_linux(), env::var("HOME").ok(), None)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user