Correct cpio's norm_path

This commit is contained in:
LoveSy 2023-11-29 15:37:03 +08:00 committed by John Wu
parent d9b67a207b
commit 6f6b0ade06

View File

@ -620,11 +620,10 @@ fn align_4(x: usize) -> usize {
#[inline(always)] #[inline(always)]
fn norm_path(path: &str) -> String { fn norm_path(path: &str) -> String {
path.strip_prefix('/') path.split('/')
.unwrap_or(path) .filter(|x| !x.is_empty())
.strip_suffix('/') .intersperse("/")
.unwrap_or(path) .collect()
.to_string()
} }
fn parse_mode(s: &str) -> Result<mode_t, String> { fn parse_mode(s: &str) -> Result<mode_t, String> {