diff options
author | Michael Hamann <michael@content-space.de> | 2011-03-08 00:33:35 +0100 |
---|---|---|
committer | Michael Hamann <michael@content-space.de> | 2011-03-08 00:33:35 +0100 |
commit | d8e733eea8ac79670ffc74ac685078dc4ac56c7e (patch) | |
tree | b036d19bd256fc3a1016ef9a1697a894dfd2b5f3 /inc/io.php | |
parent | dea1115b59e771c401882590426074c08fed3a87 (diff) | |
parent | ad79cb7c93a655f864c633433e743b03685b5719 (diff) | |
download | rpg-d8e733eea8ac79670ffc74ac685078dc4ac56c7e.tar.gz rpg-d8e733eea8ac79670ffc74ac685078dc4ac56c7e.tar.bz2 |
Merge branch 'indexer_rewrite'
Diffstat (limited to 'inc/io.php')
-rw-r--r-- | inc/io.php | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/inc/io.php b/inc/io.php index 559f3febc..034ac650e 100644 --- a/inc/io.php +++ b/inc/io.php @@ -529,7 +529,7 @@ function io_rename($from,$to){ /** - * Runs an external command and returns it's output as string + * Runs an external command and returns its output as string * * @author Harry Brueckner <harry_b@eml.cc> * @author Andreas Gohr <andi@splitbrain.org> @@ -547,6 +547,27 @@ function io_runcmd($cmd){ } /** + * Runs an external command with input and output pipes. + * Returns the exit code from the process. + * + * @author Tom N Harris <tnharris@whoopdedo.org> + */ +function io_exec($cmd, $input, &$output){ + $descspec = array( + 0=>array("pipe","r"), + 1=>array("pipe","w"), + 2=>array("pipe","w")); + $ph = proc_open($cmd, $descspec, $pipes); + if(!$ph) return -1; + fclose($pipes[2]); // ignore stderr + fwrite($pipes[0], $input); + fclose($pipes[0]); + $output = stream_get_contents($pipes[1]); + fclose($pipes[1]); + return proc_close($ph); +} + +/** * Search a file for matching lines * * This is probably not faster than file()+preg_grep() but less |