protected function flushDirectory($path, $delete = false)
    {
        if (is_dir($path)) {
            $entries = scandir($path);
            foreach ($entries as $entry) {
                $exclude = array_merge(array('.', '..'), $this->exclude);
                if (in_array($entry, $exclude)) {
                    continue;
                }
                $entryPath = $path . '/' . $entry;
                if (!is_link($entryPath) && is_dir($entryPath)) {
                    $this->flushDirectory($entryPath, true);
                } else {
                    unlink($entryPath);
                }
            }
            if ($delete) {
                rmdir($path);
            }
        }
    }
protected function flushDirectory($path, $delete = false)
    {
        if (is_dir($path)) {
            $entries = scandir($path);
            foreach ($entries as $entry) {
                $exclude = array_merge(array('.', '..'), $this->exclude);
                if (in_array($entry, $exclude)) {
                    continue;
                }
                $entryPath = $path . '/' . $entry;
                if (!is_link($entryPath) && is_dir($entryPath)) {
                    $this->flushDirectory($entryPath, true);
                } else {
                    unlink($entryPath);
                }
            }
            if ($delete) {
                rmdir($path);
            }
        }
    }
protected function flushDirectory ( $ path , $ delete = false ) { if ( is_dir ( $ path ) ) { $ entries = scandir ( $ path ) ; foreach ( $ entries as $ entry ) { $ exclude = array_merge ( array ( '.' , '..' ) , $ this -> exclude ) ; if ( in_array ( $ entry , $ exclude ) ) { continue ; } $ entryPath = $ path . '/' . $ entry ; if ( ! is_link ( $ entryPath ) && is_dir ( $ entryPath ) ) { $ this -> flushDirectory ( $ entryPath , true ) ; } else { unlink ( $ entryPath ) ; } } if ( $ delete ) { rmdir ( $ path ) ; } } }
Flushes a directory recursively.
@param string $path the directory path.
@param boolean $delete whether to delete the directory.
Flushes a directory recursively .