src/sb/PDO/Mysql/Backup.php
protected function recursiveDelete($dir, $del = 0)
    {

        if (substr($dir, 0, 1) == '/') {
            throw new \Exception("You cannot delete root directories");
        }

        $iterator = new \RecursiveDirectoryIterator($dir);
        foreach (new \RecursiveIteratorIterator($iterator, \RecursiveIteratorIterator::CHILD_FIRST) as $file) {
            $name = $file->getFilename();
            if ($file->isDir() && $name != '.' && $name != '..') {
                rmdir($file->getPathname());
            } elseif ($file->isFile()) {
                unlink($file->getPathname());
            }
        }

        if ($del == 1) {
            rmdir($dir);
        }
    }
protected function recursiveDelete($dir, $del = 0)
    {

        if (substr($dir, 0, 1) == '/') {
            throw new \Exception("You cannot delete root directories");
        }

        $iterator = new \RecursiveDirectoryIterator($dir);
        foreach (new \RecursiveIteratorIterator($iterator, \RecursiveIteratorIterator::CHILD_FIRST) as $file) {
            $name = $file->getFilename();
            if ($file->isDir() && $name != '.' && $name != '..') {
                rmdir($file->getPathname());
            } elseif ($file->isFile()) {
                unlink($file->getPathname());
            }
        }

        if ($del == 1) {
            rmdir($dir);
        }
    }
protected function recursiveDelete ( $ dir , $ del = 0 ) { if ( substr ( $ dir , 0 , 1 ) == '/' ) { throw new \ Exception ( "You cannot delete root directories" ) ; } $ iterator = new \ RecursiveDirectoryIterator ( $ dir ) ; foreach ( new \ RecursiveIteratorIterator ( $ iterator , \ RecursiveIteratorIterator :: CHILD_FIRST ) as $ file ) { $ name = $ file -> getFilename ( ) ; if ( $ file -> isDir ( ) && $ name != '.' && $ name != '..' ) { rmdir ( $ file -> getPathname ( ) ) ; } elseif ( $ file -> isFile ( ) ) { unlink ( $ file -> getPathname ( ) ) ; } } if ( $ del == 1 ) { rmdir ( $ dir ) ; } }
Recursively deletes the files in a diretory

@param string $dir The directory path
@param boolean $del Should directory itself be deleted upon completion
@return boolean
Recursively deletes the files in a diretory