You are here

function node_gallery_clean_empty_dirs in Node Gallery 6.3

Same name and namespace in other branches
  1. 6.2 node_gallery.inc \node_gallery_clean_empty_dirs()

Recursively removes empty directories up to the files directory.

Parameters

$dirname: A path to start pruning from.

1 call to node_gallery_clean_empty_dirs()
node_gallery_delete_image in ./node_gallery.inc
Deletes an image from the database, cleans the filesystem of imagecache files.

File

./node_gallery.inc, line 856
Shared functions for node_gallery

Code

function node_gallery_clean_empty_dirs($dirname) {
  if (empty($dirname)) {
    return;
  }

  // Recursively delete parent directories that are empty, up to the 'files' directory.
  $files = file_scan_directory($dirname, '.*', array(
    '.',
    '..',
  ), 0, FALSE);
  if (count($files) > 0 || $dirname == file_directory_path()) {
    return;
  }
  else {
    if (is_dir($dirname)) {
      rmdir($dirname);
    }
    $dirname = dirname($dirname);
    node_gallery_clean_empty_dirs($dirname);
  }
}