diff options
Diffstat (limited to 'crates/shirabe-external-packages/src/symfony')
7 files changed, 23 insertions, 34 deletions
diff --git a/crates/shirabe-external-packages/src/symfony/console/helper/question_helper.rs b/crates/shirabe-external-packages/src/symfony/console/helper/question_helper.rs index 2091225d..f5242d9a 100644 --- a/crates/shirabe-external-packages/src/symfony/console/helper/question_helper.rs +++ b/crates/shirabe-external-packages/src/symfony/console/helper/question_helper.rs @@ -685,7 +685,7 @@ impl QuestionHelper { input_stream: &shirabe_php_shim::PhpResource, trimmable: bool, ) -> anyhow::Result<Result<String, RuntimeException>> { - if shirabe_php_shim::DIRECTORY_SEPARATOR == "\\" { + if std::path::MAIN_SEPARATOR == '\\' { let mut exe = format!( "{}/../Resources/bin/hiddeninput.exe", shirabe_php_shim::dir() diff --git a/crates/shirabe-external-packages/src/symfony/console/output/stream_output.rs b/crates/shirabe-external-packages/src/symfony/console/output/stream_output.rs index 9140dbc8..8ee2f186 100644 --- a/crates/shirabe-external-packages/src/symfony/console/output/stream_output.rs +++ b/crates/shirabe-external-packages/src/symfony/console/output/stream_output.rs @@ -98,8 +98,7 @@ impl StreamOutput { return false; } - if "\\" == shirabe_php_shim::DIRECTORY_SEPARATOR - && shirabe_php_shim::sapi_windows_vt100_support(stream) + if std::path::MAIN_SEPARATOR == '\\' && shirabe_php_shim::sapi_windows_vt100_support(stream) { return true; } diff --git a/crates/shirabe-external-packages/src/symfony/console/terminal.rs b/crates/shirabe-external-packages/src/symfony/console/terminal.rs index 7fca27e8..353dffcb 100644 --- a/crates/shirabe-external-packages/src/symfony/console/terminal.rs +++ b/crates/shirabe-external-packages/src/symfony/console/terminal.rs @@ -69,7 +69,7 @@ impl Terminal { let result = shirabe_php_shim::shell_exec(&format!( "stty 2> {}", - if shirabe_php_shim::DIRECTORY_SEPARATOR == "\\" { + if std::path::MAIN_SEPARATOR == '\\' { "NUL" } else { "/dev/null" @@ -81,7 +81,7 @@ impl Terminal { } fn init_dimensions() { - if shirabe_php_shim::DIRECTORY_SEPARATOR == "\\" { + if std::path::MAIN_SEPARATOR == '\\' { let ansicon = shirabe_php_shim::getenv("ANSICON"); let mut matches: Vec<Option<String>> = Vec::new(); if let Some(ansicon) = &ansicon diff --git a/crates/shirabe-external-packages/src/symfony/filesystem/filesystem.rs b/crates/shirabe-external-packages/src/symfony/filesystem/filesystem.rs index 8834f724..0aba97fb 100644 --- a/crates/shirabe-external-packages/src/symfony/filesystem/filesystem.rs +++ b/crates/shirabe-external-packages/src/symfony/filesystem/filesystem.rs @@ -201,7 +201,7 @@ impl Filesystem { if shirabe_php_shim::is_link(&file) { // See https://bugs.php.net/52176 if !(shirabe_php_shim::unlink(&file) - || shirabe_php_shim::DIRECTORY_SEPARATOR != "\\" + || std::path::MAIN_SEPARATOR != '\\' || shirabe_php_shim::rmdir(&file)) && shirabe_php_shim::file_exists(&file) { @@ -272,7 +272,7 @@ impl Filesystem { let mut origin_dir = origin_dir.to_string(); let mut target_dir = target_dir.to_string(); - if shirabe_php_shim::DIRECTORY_SEPARATOR == "\\" { + if std::path::MAIN_SEPARATOR == '\\' { origin_dir = shirabe_php_shim::strtr(&origin_dir, "/", "\\"); target_dir = shirabe_php_shim::strtr(&target_dir, "/", "\\"); diff --git a/crates/shirabe-external-packages/src/symfony/process/executable_finder.rs b/crates/shirabe-external-packages/src/symfony/process/executable_finder.rs index 3c44b4ad..a00a302c 100644 --- a/crates/shirabe-external-packages/src/symfony/process/executable_finder.rs +++ b/crates/shirabe-external-packages/src/symfony/process/executable_finder.rs @@ -25,7 +25,7 @@ impl ExecutableFinder { pub fn find(&self, name: &str, default: Option<&str>, extra_dirs: &[String]) -> Option<String> { // windows built-in commands that are present in cmd.exe should not be resolved using PATH as they do not exist as exes - if shirabe_php_shim::DIRECTORY_SEPARATOR == "\\" + if std::path::MAIN_SEPARATOR == '\\' && CMD_BUILTINS.contains(&shirabe_php_shim::strtolower(name).as_str()) { return Some(name.to_string()); @@ -39,7 +39,7 @@ impl ExecutableFinder { dirs.extend_from_slice(extra_dirs); let mut suffixes: Vec<String> = vec![]; - if shirabe_php_shim::DIRECTORY_SEPARATOR == "\\" { + if std::path::MAIN_SEPARATOR == '\\' { let path_ext = shirabe_php_shim::getenv("PATHEXT").map(|v| v.to_string_lossy().into_owned()); suffixes = self.suffixes.clone(); @@ -68,13 +68,9 @@ impl ExecutableFinder { for suffix in &suffixes { for dir in &dirs { let dir = if dir.is_empty() { "." } else { dir.as_str() }; - let file = format!( - "{dir}{}{name}{suffix}", - shirabe_php_shim::DIRECTORY_SEPARATOR - ); + let file = format!("{dir}{}{name}{suffix}", std::path::MAIN_SEPARATOR); if shirabe_php_shim::is_file(&file) - && (shirabe_php_shim::DIRECTORY_SEPARATOR == "\\" - || shirabe_php_shim::is_executable(&file)) + && (std::path::MAIN_SEPARATOR == '\\' || shirabe_php_shim::is_executable(&file)) { return Some(file); } @@ -88,12 +84,9 @@ impl ExecutableFinder { } } - if shirabe_php_shim::DIRECTORY_SEPARATOR == "\\" + if std::path::MAIN_SEPARATOR == '\\' || name.len() - != shirabe_php_shim::strcspn( - name, - &format!("/{}", shirabe_php_shim::DIRECTORY_SEPARATOR), - ) + != shirabe_php_shim::strcspn(name, &format!("/{}", std::path::MAIN_SEPARATOR)) { return default.map(ToString::to_string); } diff --git a/crates/shirabe-external-packages/src/symfony/process/pipes/windows_pipes.rs b/crates/shirabe-external-packages/src/symfony/process/pipes/windows_pipes.rs index 72a28e7d..c4236743 100644 --- a/crates/shirabe-external-packages/src/symfony/process/pipes/windows_pipes.rs +++ b/crates/shirabe-external-packages/src/symfony/process/pipes/windows_pipes.rs @@ -17,7 +17,7 @@ pub struct WindowsPipes { impl WindowsPipes { pub fn new(_input: PhpMixed) -> Self { - // Windows-only path: never constructed on POSIX (DIRECTORY_SEPARATOR is "/"). + // Windows-only path: never constructed on POSIX (MAIN_SEPARATOR is '/'). todo!() } } diff --git a/crates/shirabe-external-packages/src/symfony/process/process.rs b/crates/shirabe-external-packages/src/symfony/process/process.rs index 3e4a818f..64ed3a84 100644 --- a/crates/shirabe-external-packages/src/symfony/process/process.rs +++ b/crates/shirabe-external-packages/src/symfony/process/process.rs @@ -245,7 +245,7 @@ impl Process { this.set_input(input)?; this.set_timeout(timeout)?; - this.use_file_handles = shirabe_php_shim::DIRECTORY_SEPARATOR == "\\"; + this.use_file_handles = std::path::MAIN_SEPARATOR == '\\'; Ok(this) } @@ -309,7 +309,7 @@ impl Process { .collect::<Vec<_>>() .join(" "); - if shirabe_php_shim::DIRECTORY_SEPARATOR != "\\" { + if std::path::MAIN_SEPARATOR != '\\' { // exec is mandatory to deal with sending a signal to the process cmd = format!("exec {}", cmd); } @@ -318,7 +318,7 @@ impl Process { CommandLine::String(s) => self.replace_placeholders(s, &env)?, }; - if shirabe_php_shim::DIRECTORY_SEPARATOR == "\\" { + if std::path::MAIN_SEPARATOR == '\\' { commandline = self.prepare_windows_command_line(&commandline, &mut env)?; } else if !self.use_file_handles && self.is_sigchild_enabled() { // last exit code is output on the fourth pipe and caught to work around --enable-sigchild @@ -414,12 +414,9 @@ impl Process { loop { self.check_timeout()?; let running = self.is_running() - && (shirabe_php_shim::DIRECTORY_SEPARATOR == "\\" + && (std::path::MAIN_SEPARATOR == '\\' || self.process_pipes.as_ref().unwrap().are_open()); - self.read_pipes( - running, - shirabe_php_shim::DIRECTORY_SEPARATOR != "\\" || !running, - ); + self.read_pipes(running, std::path::MAIN_SEPARATOR != '\\' || !running); if !running { break; } @@ -644,7 +641,7 @@ impl Process { /// Enables or disables the TTY mode. pub fn set_tty(&mut self, tty: bool) -> anyhow::Result<&mut Self> { - if shirabe_php_shim::DIRECTORY_SEPARATOR == "\\" && tty { + if std::path::MAIN_SEPARATOR == '\\' && tty { return Err(RuntimeException::new( "TTY mode is not supported on Windows platform.".to_string(), ) @@ -743,7 +740,7 @@ impl Process { /// Creates the descriptors needed by the proc_open. fn get_descriptors(&mut self) -> Vec<Descriptor> { // TODO(plugin): $this->input instanceof \Iterator -> rewind() is not modeled. - if shirabe_php_shim::DIRECTORY_SEPARATOR == "\\" { + if std::path::MAIN_SEPARATOR == '\\' { self.process_pipes = Some(Box::new(WindowsPipes::new(self.input.clone()))); } else { self.process_pipes = Some(Box::new(UnixPipes::new( @@ -818,7 +815,7 @@ impl Process { self.read_pipes( running && blocking, - shirabe_php_shim::DIRECTORY_SEPARATOR != "\\" || !running, + std::path::MAIN_SEPARATOR != '\\' || !running, ); if !self.fallback_status.is_empty() && self.is_sigchild_enabled() { @@ -999,7 +996,7 @@ impl Process { Some(pid) => pid, }; - if shirabe_php_shim::DIRECTORY_SEPARATOR == "\\" { + if std::path::MAIN_SEPARATOR == '\\' { let mut output: Vec<String> = Vec::new(); let mut exit_code: i64 = 0; shirabe_php_shim::exec( @@ -1192,7 +1189,7 @@ impl Process { None | Some("") => return "\"\"".to_string(), Some(a) => a, }; - if shirabe_php_shim::DIRECTORY_SEPARATOR != "\\" { + if std::path::MAIN_SEPARATOR != '\\' { return format!("'{}'", argument.replace('\'', "'\\''")); } let mut argument = argument.to_string(); |
