diff --git a/src/Util/Exception/TemporaryFileException.php b/src/Util/Exception/TemporaryFileException.php new file mode 100644 index 0000000000..668185f958 --- /dev/null +++ b/src/Util/Exception/TemporaryFileException.php @@ -0,0 +1,37 @@ +. + +// }}} + +namespace App\Util\Exception; + +/** + * Exception wrapper for TemporaryFile errors + * + * @category Exception + * @package GNUsocial + * + * @author Alexei Sorokin + * @author Hugo Sales + * @copyright 2020, 2021 Free Software Foundation, Inc http://www.fsf.org + * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later + */ +class TemporaryFileException extends \Exception +{ +} diff --git a/src/Util/TemporaryFile.php b/src/Util/TemporaryFile.php index 336bdea2e5..7740105eef 100644 --- a/src/Util/TemporaryFile.php +++ b/src/Util/TemporaryFile.php @@ -19,6 +19,8 @@ namespace App\Util; +use App\Util\Exception\TemporaryFileException; + /** * Class oriented at providing automatic temporary file handling. * @@ -39,9 +41,10 @@ class TemporaryFile extends \SplFileInfo */ public function __construct( ?string $prefix = null, + ?string $suffix = null, ?string $mode = null ) { - $filename = tempnam(sys_get_temp_dir(), $prefix ?? 'gs-php'); + $filename = tempnam(sys_get_temp_dir(), $prefix ?? 'gs-php') . ($suffix ?? ''); if ($filename === false) { throw new TemporaryFileException('Could not create file: ' . $filename);