You are here

function _tinybrowser_recursive_thumbnail_delete in TinyBrowser 7

1 call to _tinybrowser_recursive_thumbnail_delete()
tinybrowser_flush_all_thumbnails in ./tinybrowser.module
Flush all thumbnail images from the image path directory and it's subdirectories

File

./tinybrowser.module, line 706

Code

function _tinybrowser_recursive_thumbnail_delete($path, $num_deleted, $delete = FALSE) {
  $dcnt = 1;
  $scnt = 1;
  $d = dir($path);
  while (($entry = $d
    ->read()) != FALSE) {
    if ($entry == '.' || $entry == '..') {
      continue;
    }
    $entry_path = $path . '/' . $entry;
    if (is_dir($entry_path)) {
      $delete = $entry == '_thumbs' ? TRUE : FALSE;
      $num_deleted += _tinybrowser_recursive_thumbnail_delete($entry_path, 0, $delete);
      $delete = FALSE;
    }
    else {
      if (is_file($entry_path) || is_link($entry_path)) {
        if ($delete) {
          unlink($entry_path);

          // file under _thumbs directory
          $num_deleted++;
          $dcnt++;
        }
        else {
          $scnt++;
        }
      }
      else {

        // unknown
      }
    }
  }
  $d
    ->close();
  if ($delete) {
    rmdir($path);
  }
  return $num_deleted;
}