src/Storage/Disk.php
public function removeDir(): bool
    {
        if (!$this->isDir()) {
            throw new AccessDeniedException(sprintf('unable to remove directory for path: "%s"', $this->path->raw), 500);
        }

        try {
            $iterator = $this->getIterator(true, \RecursiveIteratorIterator::CHILD_FIRST);

            /** @var \SplFileInfo $file */
            foreach ($iterator as $splFile) {

                // file not readable
                if (!$splFile->isReadable()) {
                    throw new AccessDeniedException(sprintf('unable to access file for path: "%s"', $splFile->getPathname()), 500);
                }

                // try to remove files/dirs/links
                switch ($splFile->getType()) {
                    case 'dir': rmdir($splFile->getRealPath()); break;
                    case 'link': unlink($splFile->getPathname()); break;
                    default: unlink($splFile->getRealPath());
                }
            }

            return rmdir($this->path->raw);
        } finally {
            $this->selfdestruct = false;
            $this->path->reload();
        }
    }
public function removeDir(): bool
    {
        if (!$this->isDir()) {
            throw new AccessDeniedException(sprintf('unable to remove directory for path: "%s"', $this->path->raw), 500);
        }

        try {
            $iterator = $this->getIterator(true, \RecursiveIteratorIterator::CHILD_FIRST);

            /** @var \SplFileInfo $file */
            foreach ($iterator as $splFile) {

                // file not readable
                if (!$splFile->isReadable()) {
                    throw new AccessDeniedException(sprintf('unable to access file for path: "%s"', $splFile->getPathname()), 500);
                }

                // try to remove files/dirs/links
                switch ($splFile->getType()) {
                    case 'dir': rmdir($splFile->getRealPath()); break;
                    case 'link': unlink($splFile->getPathname()); break;
                    default: unlink($splFile->getRealPath());
                }
            }

            return rmdir($this->path->raw);
        } finally {
            $this->selfdestruct = false;
            $this->path->reload();
        }
    }
public function removeDir ( ) : bool { if ( ! $ this -> isDir ( ) ) { throw new AccessDeniedException ( sprintf ( 'unable to remove directory for path: "%s"' , $ this -> path -> raw ) , 500 ) ; } try { $ iterator = $ this -> getIterator ( true , \ RecursiveIteratorIterator :: CHILD_FIRST ) ; /** @var \SplFileInfo $file */ foreach ( $ iterator as $ splFile ) { // file not readable if ( ! $ splFile -> isReadable ( ) ) { throw new AccessDeniedException ( sprintf ( 'unable to access file for path: "%s"' , $ splFile -> getPathname ( ) ) , 500 ) ; } // try to remove files/dirs/links switch ( $ splFile -> getType ( ) ) { case 'dir' : rmdir ( $ splFile -> getRealPath ( ) ) ; break ; case 'link' : unlink ( $ splFile -> getPathname ( ) ) ; break ; default : unlink ( $ splFile -> getRealPath ( ) ) ; } } return rmdir ( $ this -> path -> raw ) ; } finally { $ this -> selfdestruct = false ; $ this -> path -> reload ( ) ; } }
removes directory from disk
@return bool
@throws AccessDeniedException
removes directory from disk