aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/shirabe/src')
-rw-r--r--crates/shirabe/src/autoload/class_loader.rs31
-rw-r--r--crates/shirabe/src/command/create_project_command.rs22
-rw-r--r--crates/shirabe/src/downloader/gzip_downloader.rs6
-rw-r--r--crates/shirabe/src/downloader/path_downloader.rs11
-rw-r--r--crates/shirabe/src/util/filesystem.rs11
5 files changed, 46 insertions, 35 deletions
diff --git a/crates/shirabe/src/autoload/class_loader.rs b/crates/shirabe/src/autoload/class_loader.rs
index 21473fb9..023812ce 100644
--- a/crates/shirabe/src/autoload/class_loader.rs
+++ b/crates/shirabe/src/autoload/class_loader.rs
@@ -383,13 +383,13 @@ impl ClassLoader {
sub_path = substr(&sub_path, 0, Some(last_pos as i64));
let search = format!("{}\\", sub_path);
if let Some(dirs) = self.prefix_dirs_psr4.get(&search) {
- let path_end = format!(
- "{}{}",
- std::path::MAIN_SEPARATOR,
- substr(&logical_path_psr4, (last_pos + 1) as i64, None)
- );
+ let path_end = substr(&logical_path_psr4, (last_pos + 1) as i64, None);
for dir in dirs {
- let file = format!("{}{}", dir, path_end);
+ let file = std::path::Path::new(dir)
+ .join(&path_end)
+ .into_os_string()
+ .into_string()
+ .unwrap();
if file_exists(&file) {
return Some(file);
}
@@ -400,7 +400,11 @@ impl ClassLoader {
// PSR-4 fallback dirs
for dir in &self.fallback_dirs_psr4 {
- let file = format!("{}{}{}", dir, std::path::MAIN_SEPARATOR, logical_path_psr4);
+ let file = std::path::Path::new(dir)
+ .join(&logical_path_psr4)
+ .into_os_string()
+ .into_string()
+ .unwrap();
if file_exists(&file) {
return Some(file);
}
@@ -432,8 +436,11 @@ impl ClassLoader {
for (prefix, dirs) in prefixes {
if Some(0) == strpos(class, prefix) {
for dir in dirs {
- let file =
- format!("{}{}{}", dir, std::path::MAIN_SEPARATOR, logical_path_psr0);
+ let file = std::path::Path::new(dir)
+ .join(&logical_path_psr0)
+ .into_os_string()
+ .into_string()
+ .unwrap();
if file_exists(&file) {
return Some(file);
}
@@ -444,7 +451,11 @@ impl ClassLoader {
// PSR-0 fallback dirs
for dir in &self.fallback_dirs_psr0 {
- let file = format!("{}{}{}", dir, std::path::MAIN_SEPARATOR, logical_path_psr0);
+ let file = std::path::Path::new(dir)
+ .join(&logical_path_psr0)
+ .into_os_string()
+ .into_string()
+ .unwrap();
if file_exists(&file) {
return Some(file);
}
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(
diff --git a/crates/shirabe/src/downloader/gzip_downloader.rs b/crates/shirabe/src/downloader/gzip_downloader.rs
index 3ddca2a4..962c5bb8 100644
--- a/crates/shirabe/src/downloader/gzip_downloader.rs
+++ b/crates/shirabe/src/downloader/gzip_downloader.rs
@@ -90,7 +90,11 @@ impl ArchiveDownloader for GzipDownloader {
.unwrap_or(""),
PATHINFO_FILENAME,
);
- let target_filepath = format!("{}{}{}", path, std::path::MAIN_SEPARATOR, filename);
+ let target_filepath = std::path::Path::new(path)
+ .join(&filename)
+ .into_os_string()
+ .into_string()
+ .unwrap();
if !Platform::is_windows() {
let command = vec![
diff --git a/crates/shirabe/src/downloader/path_downloader.rs b/crates/shirabe/src/downloader/path_downloader.rs
index 4be835cd..6a496c6a 100644
--- a/crates/shirabe/src/downloader/path_downloader.rs
+++ b/crates/shirabe/src/downloader/path_downloader.rs
@@ -380,12 +380,11 @@ impl DownloaderInterface for PathDownloader {
{
let absolute_path =
if !self.inner.filesystem.borrow_mut().is_absolute_path(&path) {
- format!(
- "{}{}{}",
- Platform::get_cwd(false)?,
- std::path::MAIN_SEPARATOR,
- path
- )
+ std::path::Path::new(&Platform::get_cwd(false)?)
+ .join(&path)
+ .into_os_string()
+ .into_string()
+ .unwrap()
} else {
path.clone()
};
diff --git a/crates/shirabe/src/util/filesystem.rs b/crates/shirabe/src/util/filesystem.rs
index a12c6d64..2c4cbcc6 100644
--- a/crates/shirabe/src/util/filesystem.rs
+++ b/crates/shirabe/src/util/filesystem.rs
@@ -488,12 +488,11 @@ impl Filesystem {
let mut result = true;
for file in &ri {
- let target_path = format!(
- "{}{}{}",
- target,
- std::path::MAIN_SEPARATOR,
- ri.get_sub_pathname()
- );
+ let target_path = Path::new(&target)
+ .join(ri.get_sub_pathname())
+ .into_os_string()
+ .into_string()
+ .unwrap();
if file.is_dir() {
self.ensure_directory_exists(&target_path)?;
} else {