function drush_mkdir

8.0.x filesystem.inc drush_mkdir($path, $required = TRUE)
6.x filesystem.inc drush_mkdir($path, $required = TRUE)
7.x filesystem.inc drush_mkdir($path, $required = TRUE)
4.x drush.inc drush_mkdir($path)
5.x filesystem.inc drush_mkdir($path, $required = TRUE)
master filesystem.inc drush_mkdir($path, $required = TRUE)

Cross-platform compatible helper function to recursively create a directory tree.

Related topics

13 calls to drush_mkdir()
drush_archive_dump in commands/core/archive.drush.inc
Command callback. Generate site archive file.
drush_download_file in includes/drush.inc
Download a file using wget, curl or file_get_contents, or via download cache.
drush_find_tmp in includes/drush.inc
Returns the path to a temporary directory.
drush_pm_download_validate in commands/pm/pm.drush.inc
Implementation of drush_COMMAND_validate().
drush_pm_version_control_backup::pre_update in commands/pm/version_control/backup.inc
Implementation of pre_update().

... See full list

File

includes/drush.inc, line 1771
The drush API implementation and helpers.

Code

function drush_mkdir($path) {
  if (!is_dir($path)) {
    if (drush_mkdir(dirname($path))) {
      if (@mkdir($path)) {
        return TRUE;
      }
      else {
        if (is_writable(dirname($path))) {
          drush_set_error('DRUSH_CREATE_DIR_FAILURE', dt('Unable to create !dir.', array('!dir' => preg_replace('/\w+\/\.\.\//', '', $path))));
        }
        else {
          drush_set_error('DRUSH_DESTINATION_NOT_WRITABLE', dt('Unable to write in !dir. Please check directory permissions.', array('!dir' => realpath(dirname($path)))));
        }
      }
    }
  }
  else {
    return TRUE;
  }
}