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/path_downloader.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'crates/shirabe/src/downloader/path_downloader.rs') diff --git a/crates/shirabe/src/downloader/path_downloader.rs b/crates/shirabe/src/downloader/path_downloader.rs index 9449e74a..4be835cd 100644 --- a/crates/shirabe/src/downloader/path_downloader.rs +++ b/crates/shirabe/src/downloader/path_downloader.rs @@ -23,8 +23,8 @@ use crate::util::ProcessExecutor; use indexmap::IndexMap; use shirabe_external_packages::symfony::filesystem::Filesystem as SymfonyFilesystem; use shirabe_php_shim::{ - DIRECTORY_SEPARATOR, PHP_WINDOWS_VERSION_MAJOR, PHP_WINDOWS_VERSION_MINOR, PhpMixed, - RuntimeException, file_exists, function_exists, impl_php_class, is_dir, realpath, + PHP_WINDOWS_VERSION_MAJOR, PHP_WINDOWS_VERSION_MINOR, PhpMixed, RuntimeException, file_exists, + function_exists, impl_php_class, is_dir, realpath, }; #[derive(Debug)] @@ -261,9 +261,9 @@ impl DownloaderInterface for PathDownloader { if format!( "{}{}", realpath(&path).unwrap_or_default(), - DIRECTORY_SEPARATOR + std::path::MAIN_SEPARATOR ) - .starts_with(&format!("{}{}", real_url, DIRECTORY_SEPARATOR)) + .starts_with(&format!("{}{}", real_url, std::path::MAIN_SEPARATOR)) { // IMPORTANT NOTICE: If you wish to change this, don't. You are wasting your time and ours. // @@ -383,7 +383,7 @@ impl DownloaderInterface for PathDownloader { format!( "{}{}{}", Platform::get_cwd(false)?, - DIRECTORY_SEPARATOR, + std::path::MAIN_SEPARATOR, path ) } else { -- cgit v1.3.1-4-g156e