mirror of
https://github.com/ouch-org/ouch.git
synced 2025-07-19 08:00:31 +00:00
fix(zip): normalize path separators for cross-platform ZIP compatibility
This commit is contained in:
parent
5d79880b67
commit
15b2b06a72
@ -242,6 +242,8 @@ where
|
|||||||
FinalError::with_title("Zip requires that all directories names are valid UTF-8")
|
FinalError::with_title("Zip requires that all directories names are valid UTF-8")
|
||||||
.detail(format!("File at '{path:?}' has a non-UTF-8 name"))
|
.detail(format!("File at '{path:?}' has a non-UTF-8 name"))
|
||||||
})?;
|
})?;
|
||||||
|
// ZIP format requires forward slashes as path separators, regardless of platform
|
||||||
|
let entry_name = entry_name.replace(std::path::MAIN_SEPARATOR, "/");
|
||||||
|
|
||||||
if metadata.is_dir() {
|
if metadata.is_dir() {
|
||||||
writer.add_directory(entry_name, options)?;
|
writer.add_directory(entry_name, options)?;
|
||||||
@ -251,6 +253,8 @@ where
|
|||||||
FinalError::with_title("Zip requires that all directories names are valid UTF-8")
|
FinalError::with_title("Zip requires that all directories names are valid UTF-8")
|
||||||
.detail(format!("File at '{target_path:?}' has a non-UTF-8 name"))
|
.detail(format!("File at '{target_path:?}' has a non-UTF-8 name"))
|
||||||
})?;
|
})?;
|
||||||
|
// ZIP format requires forward slashes as path separators, regardless of platform
|
||||||
|
let target_name = target_name.replace(std::path::MAIN_SEPARATOR, "/");
|
||||||
|
|
||||||
// This approach writes the symlink target path as the content of the symlink entry.
|
// This approach writes the symlink target path as the content of the symlink entry.
|
||||||
// We detect symlinks during extraction by checking for the Unix symlink mode (0o120000) in the entry's permissions.
|
// We detect symlinks during extraction by checking for the Unix symlink mode (0o120000) in the entry's permissions.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user