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

feat: add join_path

This commit is contained in:
2020-12-30 00:19:24 +08:00
parent 17c06e304d
commit 1a3c8cbeb4
2 changed files with 10 additions and 1 deletions

View File

@@ -1,6 +1,6 @@
[package]
name = "rust_util"
version = "0.6.23"
version = "0.6.24"
authors = ["Hatter Jiang <jht5945@gmail.com>"]
edition = "2018"
description = "Hatter's Rust Util"

View File

@@ -60,6 +60,15 @@ impl Iterator for JoinFilesReader {
}
}
pub fn join_path(path1: &str, path2: &str) -> String {
let sp = if util_os::is_macos_or_linux() { "/" } else { "\\" };
if path1.ends_with(sp) {
path1.to_string() + path2
} else {
path1.to_string() + sp + path2
}
}
pub fn find_parents_exists_file(file: &str) -> Option<PathBuf> {
let mut loop_count = 0_usize;
match PathBuf::from(".").canonicalize() {