public function purgePath($path)
    {
        if (false === file_exists($path)) {
            throw FileSystemException::invalidPath($path);
        }

        if (is_dir($path)) {
            if (false === ($dh = @ opendir($path))) {
                throw FileSystemException::lastError($path);
            }

            while (false !== ($item = readdir($dh))) {
                if (('.' === $item) || ('..' === $item)) {
                    continue;
                }

                $this->purgePath($path . DIRECTORY_SEPARATOR . $item);
            }

            closedir($dh);

            if (false === @ rmdir($path)) {
                throw FileSystemException::lastError($path);
            }
        } else {
            if (false === @ unlink($path)) {
                throw FileSystemException::lastError($path);
            }
        }
    }
public function purgePath($path)
    {
        if (false === file_exists($path)) {
            throw FileSystemException::invalidPath($path);
        }

        if (is_dir($path)) {
            if (false === ($dh = @ opendir($path))) {
                throw FileSystemException::lastError($path);
            }

            while (false !== ($item = readdir($dh))) {
                if (('.' === $item) || ('..' === $item)) {
                    continue;
                }

                $this->purgePath($path . DIRECTORY_SEPARATOR . $item);
            }

            closedir($dh);

            if (false === @ rmdir($path)) {
                throw FileSystemException::lastError($path);
            }
        } else {
            if (false === @ unlink($path)) {
                throw FileSystemException::lastError($path);
            }
        }
    }
public function purgePath ( $ path ) { if ( false === file_exists ( $ path ) ) { throw FileSystemException :: invalidPath ( $ path ) ; } if ( is_dir ( $ path ) ) { if ( false === ( $ dh = @ opendir ( $ path ) ) ) { throw FileSystemException :: lastError ( $ path ) ; } while ( false !== ( $ item = readdir ( $ dh ) ) ) { if ( ( '.' === $ item ) || ( '..' === $ item ) ) { continue ; } $ this -> purgePath ( $ path . DIRECTORY_SEPARATOR . $ item ) ; } closedir ( $ dh ) ; if ( false === @ rmdir ( $ path ) ) { throw FileSystemException :: lastError ( $ path ) ; } } else { if ( false === @ unlink ( $ path ) ) { throw FileSystemException :: lastError ( $ path ) ; } } }
Recursively deletes a file or directory tree.

@param string $path The file or directory path.

@throws FileSystemException If the path could not be purged.
s
Recursively deletes a file or directory tree .