summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Haug2009-03-19 01:50:08 (GMT)
committer Nathan Haug2009-03-19 01:50:08 (GMT)
commitc16fe5d3f6cffca7dfc726728c44da95521cd8bb (patch)
tree15d3ae4b870bb8a3af12c26578090b76b8523a47
parentdc1623bb79219c27cc41f879f8b14b53f63f380e (diff)
Code style fixes.
-rw-r--r--field_file.inc27
1 files changed, 18 insertions, 9 deletions
diff --git a/field_file.inc b/field_file.inc
index b035cfa..e41dce2 100644
--- a/field_file.inc
+++ b/field_file.inc
@@ -293,8 +293,11 @@ function _field_file_cache($file = NULL, $reset = FALSE) {
}
/**
- * A silent version of file.inc:file_check_directory it's only talkative
- * on errors.
+ * A silent version of file.inc's file_check_directory().
+ *
+ * This function differs from file_check_directory in that it checks for
+ * files when doing the directory check and it does not use drupal_set_message()
+ * when creating directories. This function may be removed in Drupal 7.
*
* Check that the directory exists and is writable. Directories need to
* have execute permissions to be considered a directory by FTP servers, etc.
@@ -311,24 +314,30 @@ function _field_file_cache($file = NULL, $reset = FALSE) {
function field_file_check_directory(&$directory, $mode = 0, $form_item = NULL) {
$directory = rtrim($directory, '/\\');
- // error if dir is a file.
+ // Error if the directory is a file.
if (is_file($directory)) {
- watchdog('file system', 'check_directory: The path %directory is a file.', array('%directory' => $directory), WATCHDOG_ERROR);
- if ($form_item) form_set_error($form_item, t('The directory %directory is a file!', array('%directory' => $directory)));
+ watchdog('file system', 'The path %directory was checked as a directory, but it is a file.', array('%directory' => $directory), WATCHDOG_ERROR);
+ if ($form_item) {
+ form_set_error($form_item, t('The directory %directory is a file and cannot be overwritten.', array('%directory' => $directory)));
+ }
return FALSE;
}
- // create the directory if it is missing.
- if (!is_dir($directory) && $mode & FILE_CREATE_DIRECTORY && !@mkdir($directory, 0775, true)) {
+ // Create the directory if it is missing.
+ if (!is_dir($directory) && $mode & FILE_CREATE_DIRECTORY && !@mkdir($directory, 0775, TRUE)) {
watchdog('file system', 'The directory %directory does not exist.', array('%directory' => $directory), WATCHDOG_ERROR);
- if ($form_item) form_set_error($form_item, t('The directory %directory does not exist.', array('%directory' => $directory)));
+ if ($form_item) {
+ form_set_error($form_item, t('The directory %directory does not exist.', array('%directory' => $directory)));
+ }
return FALSE;
}
// Check to see if the directory is writable.
if (!is_writable($directory) && $mode & FILE_MODIFY_PERMISSIONS && !@chmod($directory, 0775)) {
watchdog('file system', 'The directory %directory is not writable, because it does not have the correct permissions set.', array('%directory' => $directory), WATCHDOG_ERROR);
- if ($form_item) form_set_error($form_item, t('The directory %directory is not writable', array('%directory' => $directory)));
+ if ($form_item) {
+ form_set_error($form_item, t('The directory %directory is not writable', array('%directory' => $directory)));
+ }
return FALSE;
}