aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/downloader/file_downloader.rs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-08-09 06:19:30 +0900
committernsfisis <nsfisis@gmail.com>2026-08-09 06:19:30 +0900
commit880a5eaad9dcdfd31563385f11ba1f63d38cfd14 (patch)
tree6f9de7b2b8331628a74287112711f65ae3eddc52 /crates/shirabe/src/downloader/file_downloader.rs
parentf3d60c7836da0d50d59a22cfd6e4692e3dc75581 (diff)
downloadphp-shirabe-880a5eaad9dcdfd31563385f11ba1f63d38cfd14.tar.gz
php-shirabe-880a5eaad9dcdfd31563385f11ba1f63d38cfd14.tar.zst
php-shirabe-880a5eaad9dcdfd31563385f11ba1f63d38cfd14.zip
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) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/downloader/file_downloader.rs')
-rw-r--r--crates/shirabe/src/downloader/file_downloader.rs17
1 files changed, 9 insertions, 8 deletions
diff --git a/crates/shirabe/src/downloader/file_downloader.rs b/crates/shirabe/src/downloader/file_downloader.rs
index 9b86ee56..ab9c3672 100644
--- a/crates/shirabe/src/downloader/file_downloader.rs
+++ b/crates/shirabe/src/downloader/file_downloader.rs
@@ -27,10 +27,10 @@ use crate::util::sync_executor;
use indexmap::IndexMap;
use shirabe_php_shim::Catch as _;
use shirabe_php_shim::{
- DIRECTORY_SEPARATOR, InvalidArgumentException, PATHINFO_BASENAME, PATHINFO_EXTENSION,
- PHP_URL_PATH, PhpMixed, RuntimeException, UnexpectedValueException, array_search, file_exists,
- filesize, get_class, hash, hash_file, impl_php_class, is_dir, is_executable, parse_url,
- pathinfo, realpath, rtrim, spl_object_hash, strlen, strpos, strtr, trim, umask, usleep,
+ InvalidArgumentException, PATHINFO_BASENAME, PATHINFO_EXTENSION, PHP_URL_PATH, PhpMixed,
+ RuntimeException, UnexpectedValueException, array_search, file_exists, filesize, get_class,
+ hash, hash_file, impl_php_class, is_dir, is_executable, parse_url, pathinfo, realpath, rtrim,
+ spl_object_hash, strlen, strpos, strtr, trim, umask, usleep,
};
use std::sync::{LazyLock, Mutex};
@@ -744,10 +744,11 @@ impl DownloaderInterface for FileDownloader {
// but in that case we ensure the directory is empty already in ProjectInstaller so no need to empty it here.
if !{
let normalized_vendor = self.filesystem.borrow_mut().normalize_path(&vendor_dir);
- let normalized_path = self
- .filesystem
- .borrow()
- .normalize_path(&format!("{}{}", path, DIRECTORY_SEPARATOR));
+ let normalized_path = self.filesystem.borrow().normalize_path(&format!(
+ "{}{}",
+ path,
+ std::path::MAIN_SEPARATOR
+ ));
strpos(&normalized_vendor, &normalized_path).is_some()
} {
self.filesystem.borrow_mut().empty_directory(path, true)?;