Edit report at https://bugs.php.net/bug.php?id=61049&edit=1
ID: 61049
Comment by: anon at anon dot anon
Reported by: kasper at webmasteren dot eu
Summary: Fopen detects non existing file
Status: Not a bug
Type: Bug
Package: Filesystem function related
Operating System: windows
PHP Version: 5.3.8, 5.3.9
Block user comment: N
Private report: N
New Comment:
Sadly this is a Windows limitation. On Windows you cannot create a file named
"con", "aux", "prn", or "nul", regardless of case. They are reserved device
names that exist for historical reasons ("con" for example is the
stdin/stdout). For some mad reason, this limitation still applies regardless of
the file extension!! Try simply in Notepad to save a file called con.txt and
it'll fail just the same.
Previous Comments:
------------------------------------------------------------------------
[2012-02-10 20:32:57] [email protected]
This is a Win32 quirk. The interface PHP uses has problems with files named
CON,
among others:
http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx
«Do not use the following reserved device names for the name of a file:
CON, PRN, AUX, NUL, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, LPT1,
LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, and LPT9. Also avoid these names
followed immediately by an extension; for example, NUL.txt is not recommended.
For more information, see Namespaces.»
------------------------------------------------------------------------
[2012-02-10 19:28:55] kasper at webmasteren dot eu
realized the version was wrong (the date)
------------------------------------------------------------------------
[2012-02-10 19:27:37] kasper at webmasteren dot eu
Description:
------------
Tested under PHP version 5.3.8 and 5.3.9, both running xdebug and a lot of
other
standard plugins.
The problem is for some reason that PHP simply cannot create / open a file
named
"../api/cache/con.js" which seems rather strange,since there is no keywords
(from what i could find) there would even suggest that it could be the reason.
i have used the software packet called "wamp".
Configuration line:
cscript /nologo configure.js "--enable-snapshot-build" "--with-pdo-oci=C:\php-
sdk\php53dev\vc9\x64\deps\instantclient_10_2\sdk,shared" "--with-oci8=C:\php-
sdk\php53dev\vc9\x64\deps\instantclient_10_2\sdk,shared" "--with-oci8-
11g=C:\php-sdk\php53dev\vc9\x64\deps\instantclient_11_2\sdk,shared" "--disable-
debug-pack" "--disable-static-analyze"
the version API:
API20090626,TS,VC9
The test script:
inside af subfolder, on a webserver, put this, and make sure that ../api/cache
folder exists.
futher more, when using the SplFileInfo the method "getType" tells me that it
is
a file. the method "getAbsolutePath" returns "c:\wamp\www\api\cache\CON" and
the
"getFileName" returns "CON.js".
Test script:
---------------
fopen("../api/cache/con.js","w");
Expected result:
----------------
Warning: fopen(../api/cache/con.js) [function.fopen]: failed to open stream:
Bad
file descriptor in C:\wamp\www\teater\indexa.php on line 3
Actual result:
--------------
Warning: fopen(../api/cache/con.js) [function.fopen]: failed to open stream:
Bad
file descriptor in C:\wamp\www\teater\indexa.php on line 3
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=61049&edit=1