function _file_prepare_directory in GoogleTagManager 7.2
Same name and namespace in other branches
- 8 google_tag.module \_file_prepare_directory()
- 7 includes/admin.inc \_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
2 calls to _file_prepare_directory()
- google_tag_requirements in ./
google_tag.install - Implements hook_requirements().
- GTMContainerManager::createAssets in includes/
entity/ manager.inc - Prepares directory for and saves snippet files for a container.
File
- ./
google_tag.module, line 310 - Provides primary Drupal hook implementations.
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;
}