summaryrefslogtreecommitdiff
path: root/it.class
diff options
context:
space:
mode:
Diffstat (limited to 'it.class')
-rw-r--r--it.class9
1 files changed, 5 insertions, 4 deletions
diff --git a/it.class b/it.class
index 768ee02..469a587 100644
--- a/it.class
+++ b/it.class
@@ -1109,7 +1109,7 @@ static function file_put($filename, $data, $p = array())
@mkdir(dirname($filename));
$tmp = $GLOBALS['ULTRAHOME'] . "/tmp";
- $tmpdir = is_dir($tmp) && stat($tmp)[0] == stat(dirname($filename))[0] ? $tmp : dirname($filename);
+ $tmpdir = is_dir($tmp) && is_writable($tmp) && stat($tmp)[0] == stat(dirname($filename))[0] ? $tmp : dirname($filename);
$tmpfile = "$tmpdir/.it_put." . basename($filename) . "." . getmypid();
if (($result = it::file_put_contents($filename == "-" ? "php://stdout" : $tmpfile, $data)) !== false && $filename != "-")
$result = rename($tmpfile, $filename);
@@ -1119,11 +1119,12 @@ static function file_put($filename, $data, $p = array())
/**
* Create an it_pipe from a file
- * @param $fn filename to read. if omitted, stdin is used.
+ * @param $p if scalar or numeric array, file name(s) to read
+ * @param $p['data'] array of lines without \n to feed into pipe
*/
-static function cat($fn = null)
+static function cat($p = null)
{
- return new it_pipe(array('fn' => $fn));
+ return new it_pipe(is_array($p) && array_key_exists('data', $p) ? $p : ['fn' => $p]);
}
/**