When calling file_check_directory() to ensure that a directory exists, the specified directory will be created if it is not found. This works fine if all the parent directories on the path exist, but breaks if they don't.

Example:
file_check_directory('/www/files/xxx/yyy', FILE_CREATE_DIRECTORY)
will succeed if /www/files/xxx exists, but fail if only /www/files exists.

This can be corrected for PHP5 and above users by using the $recursive flag when mkdir is called. If PHP 4 is detected, the path would need to be built a level at a time, from a loop.

This fix would also require passing a $mode argument to mkdir, which would need to be also added to file_check_directory().

Comments

btully’s picture

subscribing

alan d.’s picture

Version: 5.x-dev » 7.x-dev
Status: Active » Closed (duplicate)

The solution is finally here for Drupal 7. It probably will not be back-ported, as PHP5 dependent solution.