ID: 47834
User updated by: whistl0r+phpbug at googlemail dot com
-Summary: tempnam() changes to %TEMP% instead of returning false
Reported By: whistl0r+phpbug at googlemail dot com
Status: Open
-Bug Type: Filesystem function related
+Bug Type: Documentation problem
Operating System: win32 only - Windows
PHP Version: 5.2.9
New Comment:
Hi,
okay - this is not a bug in PHP. It is a documentation problem.
The english version of the documentation says:
"If the directory does not exist, tempnam() may generate a file in the
system's temporary directory, and return the name of that."
But that's wrong/not correct.
tempnam() will fall back to the system's temporary directory everytime
it cannot write to the specified directory.
So I don't know in what circumstances this function will return
"false".. but anyway... ;)
Previous Comments:
------------------------------------------------------------------------
[2009-03-30 02:35:05] whistl0r+phpbug at googlemail dot com
Description:
------------
I wanted to check, how tempnam() handles file system limits.
On NTFS, just 65535 files per directory are allowed.
Reproduce code:
---------------
<?php
// Keep script alive
ignore_user_abort(1);
@set_time_limit(0);
$dir = 'C:\Test';
(if (!file_exists($dir))
{
// Create Test directory
mkdir($dir, null, true);
}
$i = 0;
while (tempnam($dir, 'Foobar'))
{
$i++;
}
printf('%u files created', $i);
Expected result:
----------------
The script should stop, because tempnam() should return "false".
The function should return "false", because when 65535 files are in the
specified directory, you reached a limit and aren't able to write to
C:\Test anymore.
Actual result:
--------------
The script will keep running.
After the 65535. file is created in C:\Test, the function will ignore
the specified directory and switch to %temp% (which is usually
C:\Windows\Temp).
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=47834&edit=1