function file_check_directory in Coder 6.2
Same name and namespace in other branches
- 5.2 scripts/coder_format/coder_format.php \file_check_directory()
 - 6 scripts/coder_format/coder_format.php \file_check_directory()
 - 7.2 scripts/coder_format/coder_format.php \file_check_directory()
 - 7 scripts/coder_format/coder_format.php \file_check_directory()
 
Check 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 containing the name of a directory path.:
$mode A Boolean value to indicate if the directory should be created: if it does not exist or made writable if it is read-only.
$form_item An optional string containing the name of a form item that: any errors will be attached to. This is useful for settings forms that require the user to specify a writable directory. If it can't be made to work, a form error will be set preventing them from saving the settings.
Return value
FALSE when directory not found, or TRUE when directory exists.
2 calls to file_check_directory()
- coder_format_recursive in scripts/
coder_format/ coder_format.inc  - Recursively process .module and .inc files in directory with coder_format_file().
 - file_check_path in scripts/
coder_format/ coder_format.php  - Checks path to see if it is a directory, or a dir/file.
 
File
- scripts/
coder_format/ coder_format.php, line 99  - Coder format shell invocation script.
 
Code
function file_check_directory(&$directory, $mode = 0, $form_item = NULL) {
  $directory = rtrim($directory, '/\\');
  // Check if directory exists.
  if (!is_dir($directory)) {
    // coder_format does not alter the filesystem. 23/01/2008 sun
    if (!file_exists($directory)) {
      drupal_set_message(t('The directory %directory does not exist.', array(
        '%directory' => $directory,
      )));
      return FALSE;
    }
  }
  // Check to see if the directory is writable.
  if (!is_writable($directory)) {
    // coder_format does not alter the filesystem. 23/01/2008 sun
    drupal_set_message(t('The directory %directory is not writable', array(
      '%directory' => $directory,
    )));
    return FALSE;
  }
  // coder_format is applied outside of Drupal in most cases. 23/01/2008 sun
  return TRUE;
}