diff --git a/Cargo.toml b/Cargo.toml index 0338048..dc7a089 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rust_util" -version = "0.6.2" +version = "0.6.3" authors = ["Hatter Jiang "] edition = "2018" description = "Hatter's Rust Util" diff --git a/src/util_file.rs b/src/util_file.rs index 60c228c..87123bc 100644 --- a/src/util_file.rs +++ b/src/util_file.rs @@ -6,10 +6,11 @@ use std::{ path::{ Path, PathBuf }, }; -use super::{ +use crate::{ iff, util_os, util_io, + util_msg, new_box_ioerror, XResult, }; @@ -83,7 +84,10 @@ pub fn find_parents_exists_file(file: &str) -> Option { Err(_) => None, Ok(mut path) => loop { loop_count += 1; - if loop_count > 1000 { panic!("Loop count more than 1000!"); } + if loop_count > 1000 { + util_msg::print_error("Loop count more than 1000!"); + return None; + } if path.join(file).is_file() { return Some(path); } @@ -100,7 +104,10 @@ pub fn find_parents_exists_dir(dir: &str) -> Option { Err(_) => None, Ok(mut path) => loop { loop_count += 1; - if loop_count > 1000 { panic!("Loop count more than 1000!"); } + if loop_count > 1000 { + util_msg::print_error("Loop count more than 1000!"); + return None; + } if path.join(dir).is_dir() { return Some(path); }