aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/util/platform.rs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-05-17 02:53:53 +0900
committernsfisis <nsfisis@gmail.com>2026-05-17 02:53:53 +0900
commita1c7e6908a26e10f6e1f23a51721664b5e2d838d (patch)
treec575c76f1b43359ed74913da4c6a2636643f1ba0 /crates/shirabe/src/util/platform.rs
parent7f606f36fef0c0467c3c0db3d0da33af486dae8a (diff)
downloadphp-shirabe-a1c7e6908a26e10f6e1f23a51721664b5e2d838d.tar.gz
php-shirabe-a1c7e6908a26e10f6e1f23a51721664b5e2d838d.tar.zst
php-shirabe-a1c7e6908a26e10f6e1f23a51721664b5e2d838d.zip
chore(style): cargo fmt
Diffstat (limited to 'crates/shirabe/src/util/platform.rs')
-rw-r--r--crates/shirabe/src/util/platform.rs29
1 files changed, 18 insertions, 11 deletions
diff --git a/crates/shirabe/src/util/platform.rs b/crates/shirabe/src/util/platform.rs
index e8f5dad..96e564f 100644
--- a/crates/shirabe/src/util/platform.rs
+++ b/crates/shirabe/src/util/platform.rs
@@ -5,11 +5,11 @@ use std::sync::Mutex;
use anyhow::Result;
use shirabe_external_packages::composer::pcre::preg::Preg;
use shirabe_php_shim::{
- defined, env_contains_key, env_get, env_set, env_unset, file_exists, file_get_contents,
- fopen, fstat, function_exists, getcwd, getenv, in_array, ini_get, is_array, is_readable,
- mb_strlen, posix_geteuid, posix_getpwuid, posix_getuid, posix_isatty, putenv, realpath,
- server_argv, server_contains_key, server_get, server_set, server_unset, stream_isatty,
- stripos, strlen, strtoupper, substr, usleep, PhpMixed, RuntimeException,
+ PhpMixed, RuntimeException, defined, env_contains_key, env_get, env_set, env_unset,
+ file_exists, file_get_contents, fopen, fstat, function_exists, getcwd, getenv, in_array,
+ ini_get, is_array, is_readable, mb_strlen, posix_geteuid, posix_getpwuid, posix_getuid,
+ posix_isatty, putenv, realpath, server_argv, server_contains_key, server_get, server_set,
+ server_unset, stream_isatty, stripos, strlen, strtoupper, substr, usleep,
};
use crate::util::process_executor::ProcessExecutor;
@@ -93,7 +93,11 @@ impl Platform {
/// Parses tildes and environment variables in paths.
pub fn expand_path(path: &str) -> String {
if Preg::is_match(r"#^~[\\/]#", path) {
- return format!("{}{}", Self::get_user_directory().unwrap(), substr(path, 1, None));
+ return format!(
+ "{}{}",
+ Self::get_user_directory().unwrap(),
+ substr(path, 1, None)
+ );
}
Preg::replace_callback(
@@ -180,7 +184,9 @@ impl Platform {
.ok()
.flatten()
.unwrap_or_default();
- if !(ini_get("open_basedir").map(|s| !s.is_empty()).unwrap_or(false))
+ if !(ini_get("open_basedir")
+ .map(|s| !s.is_empty())
+ .unwrap_or(false))
&& is_readable("/proc/version")
&& stripos(&file_contents, "microsoft").is_some()
&& !Self::is_docker()
@@ -206,7 +212,10 @@ impl Platform {
}
// cannot check so assume no
- if ini_get("open_basedir").map(|s| !s.is_empty()).unwrap_or(false) {
+ if ini_get("open_basedir")
+ .map(|s| !s.is_empty())
+ .unwrap_or(false)
+ {
*cached = Some(false);
return false;
}
@@ -294,9 +303,7 @@ impl Platform {
// detect msysgit/mingw and assume this is a tty because detection
// does not work correctly, see https://github.com/composer/composer/issues/9690
if in_array(
- PhpMixed::String(strtoupper(
- &Self::get_env("MSYSTEM").unwrap_or_default(),
- )),
+ PhpMixed::String(strtoupper(&Self::get_env("MSYSTEM").unwrap_or_default())),
&PhpMixed::List(vec![
Box::new(PhpMixed::String("MINGW32".to_string())),
Box::new(PhpMixed::String("MINGW64".to_string())),