From ff17dcdb757656c5e81b10070a7bbcc4ef3e97f7 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 9 Aug 2026 06:39:08 +0900 Subject: refactor(path): build paths with Path::join Concatenating a directory, MAIN_SEPARATOR and a component reimplements what Path::join already does. Joining directly also drops the separator from the intermediate values it used to be baked into, such as ClassLoader's $pathEnd. Co-Authored-By: Claude Opus 5 (1M context) --- .../shirabe/src/command/create_project_command.rs | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'crates/shirabe/src/command/create_project_command.rs') diff --git a/crates/shirabe/src/command/create_project_command.rs b/crates/shirabe/src/command/create_project_command.rs index 3849d93d..048d7b59 100644 --- a/crates/shirabe/src/command/create_project_command.rs +++ b/crates/shirabe/src/command/create_project_command.rs @@ -458,12 +458,11 @@ impl CreateProjectCommand { let mut directory = match directory { None => { let mut parts = explode_with_limit("/", &name, 2); - format!( - "{}{}{}", - Platform::get_cwd(false)?, - std::path::MAIN_SEPARATOR, - array_pop(&mut parts).unwrap_or_default() - ) + std::path::Path::new(&Platform::get_cwd(false)?) + .join(array_pop(&mut parts).unwrap_or_default()) + .into_os_string() + .into_string() + .unwrap() } Some(directory) => directory, }; @@ -474,12 +473,11 @@ impl CreateProjectCommand { )))); let fs = std::rc::Rc::new(std::cell::RefCell::new(Filesystem::new(Some(process)))); if !fs.borrow().is_absolute_path(&directory) { - directory = format!( - "{}{}{}", - Platform::get_cwd(false)?, - std::path::MAIN_SEPARATOR, - directory - ); + directory = std::path::Path::new(&Platform::get_cwd(false)?) + .join(&directory) + .into_os_string() + .into_string() + .unwrap(); } if directory.is_empty() { return Err(UnexpectedValueException::new( -- cgit v1.3.1-4-g156e