You are here

function gallery_assist_delete_directory in Gallery Assist 6

Delete the prev and thumbnail dicectories if the node will be deleted.

Parameters

$dir: A string containing the path to the directory should be deleted.

@return TRUE if finish.

2 calls to gallery_assist_delete_directory()
gallery_assist_delete in ./gallery_assist.module
Implementation of hook_delete().
gallery_assist_update in ./gallery_assist.module
Implementation of hook_update().

File

./gallery_assist.module, line 3373
Drupal content type with gallery functionality.

Code

function gallery_assist_delete_directory($dir) {
  if (!file_exists($dir)) {
    return TRUE;
  }
  if (!is_dir($dir) || is_link($dir)) {
    return unlink($dir);
  }
  foreach (scandir($dir) as $item) {
    if ($item == '.' || $item == '..') {
      continue;
    }
    if (!gallery_assist_delete_directory($dir . "/" . $item)) {
      chmod($dir . "/" . $item, 0777);
      if (!gallery_assist_delete_directory($dir . "/" . $item)) {
        return FALSE;
      }
    }
  }
  return rmdir($dir);
}