summaryrefslogtreecommitdiff
path: root/it.class
diff options
context:
space:
mode:
authorUrban Müller2019-04-06 01:07:10 +0200
committerUrban Müller2019-04-06 01:07:10 +0200
commitda49744afaa628059b84336f11fc694ceccb3a6c (patch)
treef34757e5bd7cf0f95e5bfe1d79b2440c057c4a84 /it.class
parent5f503cf2949eca81810dcba0b9d5290913a5ce8a (diff)
downloaditools-da49744afaa628059b84336f11fc694ceccb3a6c.tar.gz
itools-da49744afaa628059b84336f11fc694ceccb3a6c.tar.bz2
itools-da49744afaa628059b84336f11fc694ceccb3a6c.zip
only use service tmp if writable
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]);
}
/**