Req #52074 [Opn->Wfx]: RFE: tempdir() countrpart to tempnam()

From: Date: Fri, 27 Aug 2021 15:51:40 +0000
Subject: Req #52074 [Opn->Wfx]: RFE: tempdir() countrpart to tempnam()
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-236125@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=52074&edit=1 ID: 52074 Updated by: cmb@php.net Reported by: php at richardneill dot org Summary: RFE: tempdir() countrpart to tempnam() -Status: Open +Status: Wont fix Type: Feature/Change Request Package: Directory function related PHP Version: Irrelevant -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: > What we effectively need is a race-free way to assign a > temp-filename without actually creating the file. How would that be possible in the general case? Even tempnam(3) is not without race-condition; a function that would return the name of a temporary directory, is as well. Given that this rather doubtful request had not much traction for more than ten years, I'm closing as WONTFIX. Feel free to pursue the RFC process[1], if you want to see this feature implemented. [1] <https://wiki.php.net/rfc/howto> Previous Comments: ------------------------------------------------------------------------ [2013-10-30 10:26:44] phpbugs at canavan dot de An alternative would be to add a flag to tempnam(), e.g. tempnam ( string $dir , string $prefix, bool $create_a_directory ). ------------------------------------------------------------------------ [2010-06-13 02:57:22] php at richardneill dot org Description: ------------ It would be really useful to have the ability to create a tempdir, with a unique name, which we know we can write to, and will be automatically cleaned up. For example, if I want to run an external command (with exec() ) which will write to a file, where: - it must be known that file-creation can succeed - the file does not exist at the moment Test script: --------------- Some applications will refuse to overwrite an existing file (that we created with tempnam()), because they don't want to clobber it. What we effectively need is a race-free way to assign a temp-filename without actually creating the file. Using tmpfile() doesn't help, because we can't pass a file-handle to php's exec(). ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=52074&edit=1

« previous php.bugs (#236125) next »