From d858969bdf1789f514683571b5fd91e1287d4c39 Mon Sep 17 00:00:00 2001 From: zxj Date: Wed, 13 Sep 2023 11:07:15 +0800 Subject: [PATCH] remove PathBuf --- src/plugin/file_split.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/plugin/file_split.rs b/src/plugin/file_split.rs index 7a6ec79..89eb305 100644 --- a/src/plugin/file_split.rs +++ b/src/plugin/file_split.rs @@ -6,7 +6,7 @@ use fastdate::DateTime; use std::cell::RefCell; use std::fs::{DirEntry, File, OpenOptions}; use std::io::{Seek, SeekFrom, Write}; -use std::path::{Path, PathBuf}; +use std::path::Path; use std::sync::atomic::{AtomicUsize, Ordering}; use std::time::Duration; @@ -244,7 +244,7 @@ pub enum RollingType { impl RollingType { fn read_paths(&self, dir: &str, temp_name: &str) -> Vec { - let base_name = get_base_name(&PathBuf::from(temp_name)); + let base_name = get_base_name(&Path::new(temp_name)); let paths = std::fs::read_dir(dir); if let Ok(paths) = paths { //let mut temp_file = None; @@ -309,8 +309,8 @@ impl RollingType { } /// parse `temp2023-07-20T10-13-17.452247.log` - pub fn file_name_parse_time(name: &str, temp_name: &str) -> Option { - let base_name = get_base_name(&PathBuf::from(temp_name)); + pub fn file_name_parse_time(name: &str, temp_name: &str) -> Option { + let base_name = get_base_name(&Path::new(temp_name)); if name.starts_with(&base_name) { let mut time_str = name.trim_start_matches(&base_name).to_string(); if let Some(v) = time_str.rfind(".") { @@ -425,7 +425,7 @@ pub fn do_pack(packer: &Box, mut pack: LogPack) -> Result String { +fn get_base_name(path: &Path) -> String { let file_name = path .file_name() .unwrap_or_default()