function file_prepare_directory

×

Error message

User warning: The following module is missing from the file system: theme/theme. For information about how to fix this, see the documentation page. in _drupal_trigger_error_with_delayed_logging() (line 1156 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
cis7 file.inc file_prepare_directory(&$directory, $options = FILE_MODIFY_PERMISSIONS)
cle7 file.inc file_prepare_directory(&$directory, $options = FILE_MODIFY_PERMISSIONS)
elmsmedia7 file.inc file_prepare_directory(&$directory, $options = FILE_MODIFY_PERMISSIONS)
icor7 file.inc file_prepare_directory(&$directory, $options = FILE_MODIFY_PERMISSIONS)
meedjum_blog7 file.inc file_prepare_directory(&$directory, $options = FILE_MODIFY_PERMISSIONS)
mooc7 file.inc file_prepare_directory(&$directory, $options = FILE_MODIFY_PERMISSIONS)

Checks that the directory exists and is writable.

Directories need to have execute permissions to be considered a directory by FTP servers, etc.

Parameters

$directory: A string reference containing the name of a directory path or URI. A trailing slash will be trimmed from a path.

$options: A bitmask to indicate if the directory should be created if it does not exist (FILE_CREATE_DIRECTORY) or made writable if it is read-only (FILE_MODIFY_PERMISSIONS).

Return value

TRUE if the directory exists (or was created) and is writable. FALSE otherwise.

Related topics

70 calls to file_prepare_directory()
advagg_create_subfile in sites/all/modules/ulmus/advagg/advagg.inc
Write CSS parts to disk; used when CSS selectors in one file is > 4096.
advagg_get_root_files_dir in sites/all/modules/ulmus/advagg/advagg.module
Get the CSS & JS path for advagg.
advagg_mod_admin_settings_form_validate in sites/all/modules/ulmus/advagg/advagg_mod/advagg_mod.admin.inc
Make sure the unified multisite directory was created correctly.
advagg_mod_advagg_get_root_files_dir_alter in sites/all/modules/ulmus/advagg/advagg_mod/advagg_mod.module
Implements hook_advagg_get_root_files_dir_alter().
advagg_requirements in sites/all/modules/ulmus/advagg/advagg.install
Implements hook_requirements().

... See full list

File

includes/file.inc, line 430
API for handling file uploads and server file management.

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 = is_writable($directory);
  if (!$writable && ($options & FILE_MODIFY_PERMISSIONS)) {
    return drupal_chmod($directory);
  }

  return $writable;
}
Error | ELMSLN API

Error

×

Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/api.elmsln.org/includes/common.inc:2791) in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/api.elmsln.org/sites/all/modules/apc/drupal_apc_cache.inc).
The website encountered an unexpected error. Please try again later.