You are here

public static function Storage::checkDirectory in Configuration Management 7.2

Returns TRUE if the path is a directory or we can create one in that path.

1 call to Storage::checkDirectory()
Storage::checkFilePermissions in lib/Drupal/configuration/Storage/Storage.php
Returns TRUE if the current user has write permissions for a configuration file in the config:// directory.

File

lib/Drupal/configuration/Storage/Storage.php, line 67
Definition of Drupal\configuration\Storage\Storage.

Class

Storage

Namespace

Drupal\configuration\Storage

Code

public static function checkDirectory($dir_path) {
  if (!is_dir($dir_path)) {
    if (drupal_mkdir($dir_path, NULL, TRUE)) {
      return TRUE;
    }
    else {

      // If the directory does not exists and cannot be created.
      drupal_set_message(st('The directory %directory does not exist and could not be created.', array(
        '%directory' => $dir_path,
      )), 'error');
      watchdog('file system', 'The directory %directory does not exist and could not be created.', array(
        '%directory' => $dir_path,
      ), WATCHDOG_ERROR);
      return FALSE;
    }
  }
  else {
    if (is_writable($dir_path) || drupal_chmod($dir_path)) {
      return TRUE;
    }
    watchdog('configuration', 'The current user does not have write permissions in the directory %dir.', array(
      '%dir' => $dir_path,
    ), WATCHDOG_ERROR);
    drupal_set_message(t('The current user does not have write permissions in the directory %dir.', array(
      '%dir' => $dir_path,
    )), 'error', FALSE);
  }
  return FALSE;
}