Edit report at https://bugs.php.net/bug.php?id=63456&edit=1

 ID:                 63456
 Updated by:         ahar...@php.net
 Reported by:        xmeltrut at gmail dot com
 Summary:            Option for fopen to create directories
-Status:             Open
+Status:             Wont fix
 Type:               Feature/Change Request
 Package:            Filesystem function related
 Operating System:   All
 PHP Version:        5.4.8
 Block user comment: N
 Private report:     N

 New Comment:

Conceptually, fopen() is really just a wrapper for the C fopen() function, 
which behaves the same way. Since mkdir() does have a recursive option, I don't 
think there's much value in adding another variation to how fopen() behaves — 
there are enough already.


Previous Comments:
------------------------------------------------------------------------
[2012-11-07 14:49:22] xmeltrut at gmail dot com

Description:
------------
Currently, fopen allows you to create new files, but not in directories that 
don't 
exist - for example, if you want to write to /tmp/logs/something.log, you have 
to 
check that /tmp/logs exists every time, before running your fopen.

It would be convenient if you could pass a flag to fopen to tell it to 
recursively 
create any missing directories in the path, in order to open the file.

Test script:
---------------
fopen('/tmp/logs/test.log', 'w'); // fails if logs doesn't exist

mkdir('/tmp/logs');
fopen('/tmp/logs/test.log', 'w'); // fails if logs does exist



------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=63456&edit=1

Reply via email to