src/Adapter/PhpFilesystemAdapter.php
/**
     * Removes the passed directory recursively.
     *
     * @param string  $src       Name of the directory to remove
     * @param boolean $recursive TRUE if the directory has to be deleted recursive, else FALSE
     *
     * @return void
     * @throws \Exception Is thrown, if the directory can not be removed
     */
Removes the passed directory recursively.
@param string  $src       Name of the directory to remove
@param boolean $recursive TRUE if the directory has to be deleted recursive, else FALSE

@return void
@throws \Exception Is thrown, if the directory can not be removed
Removes the passed directory recursively . @param string $src Name of the directory to remove @param boolean $recursive TRUE if the directory has to be deleted recursive else FALSE @return void @throws \ Exception Is thrown if the directory can not be removed
public function removeDir($src, $recursive = false)
    {
        $dir = opendir($src);
        while (false !== ($file = readdir($dir))) {
            if (($file != '.') && ($file != '..')) {
                $full = $src . '/' . $file;
                if ($this->isDir($full)) {
                    $recursive ?? $this->removeDir($full, $recursive);
                } else {
                    if (!$this->delete($full)) {
                        throw new \Exception(sprintf('Can\'t remove file %s', $full));
                    }
                }
            }
        }
        closedir($dir);
        if (!rmdir($src)) {
            throw new \Exception(sprintf('Can\'t remove directory %s', $src));
        }
    }
public function removeDir ( $ src , $ recursive = false ) { $ dir = opendir ( $ src ) ; while ( false !== ( $ file = readdir ( $ dir ) ) ) { if ( ( $ file != '.' ) && ( $ file != '..' ) ) { $ full = $ src . '/' . $ file ; if ( $ this -> isDir ( $ full ) ) { $ recursive ?? $ this -> removeDir ( $ full , $ recursive ) ; } else { if ( ! $ this -> delete ( $ full ) ) { throw new \ Exception ( sprintf ( 'Can\'t remove file %s' , $ full ) ) ; } } } } closedir ( $ dir ) ; if ( ! rmdir ( $ src ) ) { throw new \ Exception ( sprintf ( 'Can\'t remove directory %s' , $ src ) ) ; } }
Removes the passed directory recursively.
Removes the passed directory recursively .
// open the directory // remove files/folders recursively // close handle and remove directory itself