You are here

function _file_prepare_directory in GoogleTagManager 7

Same name and namespace in other branches
  1. 8 google_tag.module \_file_prepare_directory()
  2. 7.2 google_tag.module \_file_prepare_directory()

Checks that the directory exists and is writable.

@todo Remove this function if core is updated to check the executable bit.

See also

file_prepare_directory()

2 calls to _file_prepare_directory()
google_tag_requirements in ./google_tag.install
Implements hook_requirements().
_google_tag_directory_prepare in includes/admin.inc
Prepares directory for base or realm specific snippet files.

File

includes/admin.inc, line 409
Contains the administrative page and form callbacks.

Code

function _file_prepare_directory(&$directory, $options = FILE_MODIFY_PERMISSIONS) {
  if (!file_stream_wrapper_valid_scheme(file_uri_scheme($directory))) {

    // Only trim if we're not dealing with a stream.
    $directory = rtrim($directory, '/\\');
  }

  // Check if directory exists.
  if (!is_dir($directory)) {

    // Let mkdir() recursively create directories and use the default directory
    // permissions.
    if ($options & FILE_CREATE_DIRECTORY && @drupal_mkdir($directory, NULL, TRUE)) {
      return drupal_chmod($directory);
    }
    return FALSE;
  }

  // The directory exists, so check to see if it is writable.
  $writable = _google_tag_is_writable($directory) && _google_tag_is_executable($directory);
  if (!$writable && $options & FILE_MODIFY_PERMISSIONS) {
    return drupal_chmod($directory);
  }
  return $writable;
}