public static function remove($path)
    {
        if (is_dir($path)) {
            if (false === ($dir = opendir($path))) {
                throw FileException::removeFailed($path);
            }

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

                self::remove($path . DIRECTORY_SEPARATOR . $item);
            }

            closedir($dir);

            if (!rmdir($path)) {
                throw FileException::removeFailed($path);
            }
        } elseif (!unlink($path)) {
            throw FileException::removeFailed($path);
        }
    }
public static function remove($path)
    {
        if (is_dir($path)) {
            if (false === ($dir = opendir($path))) {
                throw FileException::removeFailed($path);
            }

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

                self::remove($path . DIRECTORY_SEPARATOR . $item);
            }

            closedir($dir);

            if (!rmdir($path)) {
                throw FileException::removeFailed($path);
            }
        } elseif (!unlink($path)) {
            throw FileException::removeFailed($path);
        }
    }
public static function remove ( $ path ) { if ( is_dir ( $ path ) ) { if ( false === ( $ dir = opendir ( $ path ) ) ) { throw FileException :: removeFailed ( $ path ) ; } while ( false !== ( $ item = readdir ( $ dir ) ) ) { if ( ( '.' === $ item ) || ( '..' === $ item ) ) { continue ; } self :: remove ( $ path . DIRECTORY_SEPARATOR . $ item ) ; } closedir ( $ dir ) ; if ( ! rmdir ( $ path ) ) { throw FileException :: removeFailed ( $ path ) ; } } elseif ( ! unlink ( $ path ) ) { throw FileException :: removeFailed ( $ path ) ; } }
Recursively removes a path from the file system.

@param string $path The path to remove.

@throws FileException If the path could not be removed.
Recursively removes a path from the file system .