function drupal_install_mkdir

Same name and namespace in other branches
  1. 7.x includes/install.inc \drupal_install_mkdir()
  2. 9 core/includes/install.inc \drupal_install_mkdir()
  3. 8.9.x core/includes/install.inc \drupal_install_mkdir()
  4. 11.x core/includes/install.inc \drupal_install_mkdir()

Creates a directory with the specified permissions.

Parameters

$file: The name of the directory to create;

$mask: The permissions of the directory to create.

$message: (optional) Whether to output messages. Defaults to TRUE.

Return value

bool TRUE/FALSE whether or not the directory was successfully created.

1 call to drupal_install_mkdir()
drupal_verify_install_file in core/includes/install.inc
Verifies the state of the specified file.

File

core/includes/install.inc, line 683

Code

function drupal_install_mkdir($file, $mask, $message = TRUE) {
  $mod = 0;
  $masks = [
    FILE_READABLE,
    FILE_WRITABLE,
    FILE_EXECUTABLE,
    FILE_NOT_READABLE,
    FILE_NOT_WRITABLE,
    FILE_NOT_EXECUTABLE,
  ];
  foreach ($masks as $m) {
    if ($mask & $m) {
      switch ($m) {
        case FILE_READABLE:
          $mod |= 0444;
          break;

        case FILE_WRITABLE:
          $mod |= 0222;
          break;

        case FILE_EXECUTABLE:
          $mod |= 0111;
          break;

      }
    }
  }
  if (@\Drupal::service('file_system')->mkdir($file, $mod)) {
    return TRUE;
  }
  else {
    return FALSE;
  }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.