Skip to content

Instantly share code, notes, and snippets.

@vijaycs85
Created February 11, 2013 18:38
Show Gist options
  • Save vijaycs85/4756532 to your computer and use it in GitHub Desktop.
Save vijaycs85/4756532 to your computer and use it in GitHub Desktop.
<?php
// If the URI has a scheme, don't override the umask - schemes can handle this
// issue in their own implementation.
if (file_uri_scheme($uri)) {
return _drupal_mkdir_call($uri, $mode, $recursive, $context);
}
// If recursive, create each missing component of the parent directory
// individually and set the mode explicitly to override the umask.
if ($recursive) {
$components = explode(DIRECTORY_SEPARATOR, $uri);
array_pop($components);
$recursive_path = '';
foreach ($components as $component) {
$recursive_path .= $component;
if (!file_exists($recursive_path)) {
if (!_drupal_mkdir_call($recursive_path, $mode, FALSE, $context)) {
return FALSE;
}
// Not necessary to use drupal_chmod() as there is no scheme.
if (!chmod($recursive_path, $mode)) {
return FALSE;
}
}
$recursive_path .= DIRECTORY_SEPARATOR;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment