You are here

function _filebrowser_rmdir in Filebrowser 7.4

Same name and namespace in other branches
  1. 7.3 filebrowser.module \_filebrowser_rmdir()

Removes a whole directory tree recursively.

Parameters

string $dir Directory to remove:

Return value

boolean TRUE on success, FALSE otherwise.

1 call to _filebrowser_rmdir()
filebrowser_form_delete_confirm_submit in ./filebrowser.module
File delete confirmation form submit

File

./filebrowser.module, line 1429

Code

function _filebrowser_rmdir($dir) {
  if (is_dir($dir)) {
    $children = scandir($dir);
    foreach ($children as $child) {
      if ($child != '.' && $child != '..') {
        $fullname = $dir . '/' . $child;
        if (is_file($fullname) || is_link($fullname)) {
          unlink($fullname);
        }
        elseif (is_dir($fullname)) {
          if (!_filebrowser_rmdir($fullname)) {
            return FALSE;
          }
        }
      }
    }
    reset($children);
    return rmdir($dir);
  }
}