aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe-external-packages/src/symfony/process/pipes
diff options
context:
space:
mode:
Diffstat (limited to 'crates/shirabe-external-packages/src/symfony/process/pipes')
-rw-r--r--crates/shirabe-external-packages/src/symfony/process/pipes/abstract_pipes.rs15
-rw-r--r--crates/shirabe-external-packages/src/symfony/process/pipes/mod.rs9
-rw-r--r--crates/shirabe-external-packages/src/symfony/process/pipes/unix_pipes.rs16
-rw-r--r--crates/shirabe-external-packages/src/symfony/process/pipes/windows_pipes.rs5
4 files changed, 18 insertions, 27 deletions
diff --git a/crates/shirabe-external-packages/src/symfony/process/pipes/abstract_pipes.rs b/crates/shirabe-external-packages/src/symfony/process/pipes/abstract_pipes.rs
index 43a6567..f9fb251 100644
--- a/crates/shirabe-external-packages/src/symfony/process/pipes/abstract_pipes.rs
+++ b/crates/shirabe-external-packages/src/symfony/process/pipes/abstract_pipes.rs
@@ -1,7 +1,7 @@
//! ref: composer/vendor/symfony/process/Pipes/AbstractPipes.php
use indexmap::IndexMap;
-use shirabe_php_shim::{self as php, PhpMixed, PhpResource};
+use shirabe_php_shim::{PhpMixed, PhpResource};
#[derive(Debug)]
pub struct AbstractPipes {
@@ -38,7 +38,7 @@ impl AbstractPipes {
pub fn close(&mut self) {
for (_, pipe) in &self.pipes {
- php::fclose(pipe);
+ shirabe_php_shim::fclose(pipe);
}
self.pipes = IndexMap::new();
}
@@ -60,7 +60,7 @@ impl AbstractPipes {
}
for (_, pipe) in &self.pipes {
- php::stream_set_blocking(pipe, false);
+ shirabe_php_shim::stream_set_blocking(pipe, false);
}
// The `is_resource($this->input)` branch does not apply: `input` is never a resource in this
// port (is_resource on a PhpMixed is always false).
@@ -81,10 +81,11 @@ impl AbstractPipes {
let mut w: Vec<PhpResource> = vec![stdin.clone()];
// let's have a look if something changed in streams
- php::stream_select(&mut r, &mut w, &mut e, 0, Some(0))?;
+ shirabe_php_shim::stream_select(&mut r, &mut w, &mut e, 0, Some(0))?;
if !self.input_buffer.is_empty() {
- let written = php::fwrite(&stdin, &self.input_buffer, None).unwrap_or(0) as usize;
+ let written =
+ shirabe_php_shim::fwrite(&stdin, &self.input_buffer, None).unwrap_or(0) as usize;
self.input_buffer = self.input_buffer.get(written..).unwrap_or("").to_string();
if !self.input_buffer.is_empty() {
return Some(vec![stdin]);
@@ -92,9 +93,9 @@ impl AbstractPipes {
}
// no input to read on resource, buffer is empty
- if self.input_buffer.is_empty() && !php::php_truthy(&self.input) {
+ if self.input_buffer.is_empty() && !shirabe_php_shim::php_truthy(&self.input) {
self.input = PhpMixed::Null;
- php::fclose(&stdin);
+ shirabe_php_shim::fclose(&stdin);
self.pipes.shift_remove(&0);
}
diff --git a/crates/shirabe-external-packages/src/symfony/process/pipes/mod.rs b/crates/shirabe-external-packages/src/symfony/process/pipes/mod.rs
deleted file mode 100644
index 6a77f5f..0000000
--- a/crates/shirabe-external-packages/src/symfony/process/pipes/mod.rs
+++ /dev/null
@@ -1,9 +0,0 @@
-pub mod abstract_pipes;
-pub mod pipes_interface;
-pub mod unix_pipes;
-pub mod windows_pipes;
-
-pub use abstract_pipes::*;
-pub use pipes_interface::*;
-pub use unix_pipes::*;
-pub use windows_pipes::*;
diff --git a/crates/shirabe-external-packages/src/symfony/process/pipes/unix_pipes.rs b/crates/shirabe-external-packages/src/symfony/process/pipes/unix_pipes.rs
index 795bb64..aff2a54 100644
--- a/crates/shirabe-external-packages/src/symfony/process/pipes/unix_pipes.rs
+++ b/crates/shirabe-external-packages/src/symfony/process/pipes/unix_pipes.rs
@@ -1,11 +1,10 @@
//! ref: composer/vendor/symfony/process/Pipes/UnixPipes.php
-use indexmap::IndexMap;
-use shirabe_php_shim::{self as php, Descriptor, PhpMixed, PhpResource};
-
use crate::symfony::process::pipes::abstract_pipes::AbstractPipes;
use crate::symfony::process::pipes::pipes_interface::{CHUNK_SIZE, PipesInterface};
use crate::symfony::process::process::Process;
+use indexmap::IndexMap;
+use shirabe_php_shim::{Descriptor, PhpMixed, PhpResource};
/// UnixPipes implementation uses unix pipes as handles.
#[derive(Debug)]
@@ -44,7 +43,8 @@ fn descriptor(items: &[&str]) -> Descriptor {
impl PipesInterface for UnixPipes {
fn get_descriptors(&mut self) -> Vec<Descriptor> {
if !self.have_read_support {
- let nullstream = php::fopen("/dev/null", "c").expect("fopen('/dev/null') failed");
+ let nullstream =
+ shirabe_php_shim::fopen("/dev/null", "c").expect("fopen('/dev/null') failed");
return vec![
descriptor(&["pipe", "r"]),
Descriptor::Resource(nullstream.clone()),
@@ -100,7 +100,7 @@ impl PipesInterface for UnixPipes {
// let's have a look if something changed in streams
if (!r_sel.is_empty() || w.is_some())
- && php::stream_select(
+ && shirabe_php_shim::stream_select(
&mut r_sel,
&mut w_sel,
&mut e_sel,
@@ -125,7 +125,7 @@ impl PipesInterface for UnixPipes {
for (fd, pipe) in &r {
let mut data = String::new();
loop {
- let chunk = php::fread(pipe, CHUNK_SIZE).unwrap_or_default();
+ let chunk = shirabe_php_shim::fread(pipe, CHUNK_SIZE).unwrap_or_default();
let len = chunk.len() as i64;
data.push_str(&chunk);
if !(len > 0 && (close || len >= CHUNK_SIZE)) {
@@ -137,8 +137,8 @@ impl PipesInterface for UnixPipes {
read.insert(*fd, data);
}
- if close && php::feof(pipe) {
- php::fclose(pipe);
+ if close && shirabe_php_shim::feof(pipe) {
+ shirabe_php_shim::fclose(pipe);
self.inner.pipes.shift_remove(fd);
}
}
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 a31f184..f721d2b 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
@@ -1,10 +1,9 @@
//! ref: composer/vendor/symfony/process/Pipes/WindowsPipes.php
-use indexmap::IndexMap;
-use shirabe_php_shim::{Descriptor, PhpMixed, PhpResource};
-
use crate::symfony::process::pipes::abstract_pipes::AbstractPipes;
use crate::symfony::process::pipes::pipes_interface::PipesInterface;
+use indexmap::IndexMap;
+use shirabe_php_shim::{Descriptor, PhpMixed, PhpResource};
/// WindowsPipes implementation uses temporary files as handles.
#[derive(Debug)]