From 880a5eaad9dcdfd31563385f11ba1f63d38cfd14 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 9 Aug 2026 06:19:30 +0900 Subject: refactor(php-shim): use std::path::MAIN_SEPARATOR over a shim constant The shim's DIRECTORY_SEPARATOR was hardcoded to "/", so every ported `'\\' === DIRECTORY_SEPARATOR` check compared against a constant that does not track the target platform. std::path::MAIN_SEPARATOR and MAIN_SEPARATOR_STR carry the same meaning as PHP's constant and resolve per platform, so the Windows branches are selected on Windows targets. Co-Authored-By: Claude Opus 5 (1M context) --- crates/shirabe/src/downloader/zip_downloader.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'crates/shirabe/src/downloader/zip_downloader.rs') diff --git a/crates/shirabe/src/downloader/zip_downloader.rs b/crates/shirabe/src/downloader/zip_downloader.rs index c481f13f..bc565ea0 100644 --- a/crates/shirabe/src/downloader/zip_downloader.rs +++ b/crates/shirabe/src/downloader/zip_downloader.rs @@ -12,10 +12,10 @@ use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; use shirabe_external_packages::symfony::process::ExecutableFinder; use shirabe_php_shim::Catch as _; use shirabe_php_shim::{ - CmpOp, DIRECTORY_SEPARATOR, ErrorException, PhpMixed, RuntimeException, - UnexpectedValueException, ZipArchive, bin2hex, class_exists, file_exists, file_get_contents, - filesize, function_exists, hash_file, impl_php_class, is_file, json_encode, php_regex, - random_int, str_contains, str_replace, strlen, substr, version_compare, + CmpOp, ErrorException, PhpMixed, RuntimeException, UnexpectedValueException, ZipArchive, + bin2hex, class_exists, file_exists, file_get_contents, filesize, function_exists, hash_file, + impl_php_class, is_file, json_encode, php_regex, random_int, str_contains, str_replace, strlen, + substr, version_compare, }; use std::sync::Mutex; @@ -84,8 +84,8 @@ impl ZipDownloader { let map: IndexMap<&str, String> = [ // normalize separators to backslashes to avoid problems with 7-zip on windows // see https://github.com/composer/composer/issues/10058 - ("%file%", file.replace('/', DIRECTORY_SEPARATOR)), - ("%path%", path.replace('/', DIRECTORY_SEPARATOR)), + ("%file%", file.replace('/', std::path::MAIN_SEPARATOR_STR)), + ("%path%", path.replace('/', std::path::MAIN_SEPARATOR_STR)), ] .into_iter() .collect(); -- cgit v1.3.1-4-g156e