drupal_verify_install_file($file, $mask = NULL, $type = 'file')
Verifies the state of the specified file.
Parameters
$file: The file to check for.
$mask: An optional bitmask created from various FILE_* constants.
$type: The type of file. Can be file (default), dir, or link.
Return value
TRUE on success or FALSE on failure. A message is set for the latter.
File
- core/includes/install.inc, line 650
- API functions for installing modules and themes.
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | function drupal_verify_install_file( $file , $mask = NULL, $type = 'file' ) { $return = TRUE; // Check for files that shouldn't be there. if (isset( $mask ) && ( $mask & FILE_NOT_EXIST) && file_exists ( $file )) { return FALSE; } // Verify that the file is the type of file it is supposed to be. if (isset( $type ) && file_exists ( $file )) { $check = 'is_' . $type ; if (!function_exists( $check ) || ! $check ( $file )) { $return = FALSE; } } // Verify file permissions. if (isset( $mask )) { $masks = array (FILE_EXIST, FILE_READABLE, FILE_WRITABLE, FILE_EXECUTABLE, FILE_NOT_READABLE, FILE_NOT_WRITABLE, FILE_NOT_EXECUTABLE); foreach ( $masks as $current_mask ) { if ( $mask & $current_mask ) { switch ( $current_mask ) { case FILE_EXIST: if (! file_exists ( $file )) { if ( $type == 'dir' ) { drupal_install_mkdir( $file , $mask ); } if (! file_exists ( $file )) { $return = FALSE; } } break ; case FILE_READABLE: if (! is_readable ( $file ) && !drupal_install_fix_file( $file , $mask )) { $return = FALSE; } break ; case FILE_WRITABLE: if (! is_writable ( $file ) && !drupal_install_fix_file( $file , $mask )) { $return = FALSE; } break ; case FILE_EXECUTABLE: if (! is_executable ( $file ) && !drupal_install_fix_file( $file , $mask )) { $return = FALSE; } break ; case FILE_NOT_READABLE: if ( is_readable ( $file ) && !drupal_install_fix_file( $file , $mask )) { $return = FALSE; } break ; case FILE_NOT_WRITABLE: if ( is_writable ( $file ) && !drupal_install_fix_file( $file , $mask )) { $return = FALSE; } break ; case FILE_NOT_EXECUTABLE: if ( is_executable ( $file ) && !drupal_install_fix_file( $file , $mask )) { $return = FALSE; } break ; } } } } return $return ; } |
Please login to continue.