From b0f1f6067066ac5c4216672181150431270611bc Mon Sep 17 00:00:00 2001 From: Urban Müller Date: Mon, 23 Jan 2017 13:40:42 +0100 Subject: tempnam() with default and warnings --- it.class | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/it.class b/it.class index 3846fe5..a9b6662 100644 --- a/it.class +++ b/it.class @@ -1082,4 +1082,16 @@ static function mod($a, $n) return (($a % $n) + $n) % $n; } +/** + * Same as php tempnam() but $dir defaults to tmp/ in service home + */ +static function tempnam($dir, $prefix) +{ + $dir = $dir ?: $GLOBALS['ULTRAHOME'] . "/tmp"; + if (!is_writable($dir)) + it::error("tempnam: '$dir' not writable"); + + return tempnam($dir, $prefix); +} + } -- cgit v1.2.3