public static function emptyDirectoryRecursively(string $path)
    {
        if (!is_dir($path)) {
            throw new FilesException('"' . $path . '" is no directory.', 1169047616);
        }

        if (self::is_link($path)) {
            if (self::unlink($path) !== true) {
                throw new FilesException('Could not unlink symbolic link "' . $path . '".', 1323697654);
            }
        } else {
            $directoryIterator = new \RecursiveDirectoryIterator($path);
            foreach ($directoryIterator as $fileInfo) {
                if (!$fileInfo->isDir()) {
                    if (self::unlink($fileInfo->getPathname()) !== true) {
                        throw new FilesException('Could not unlink file "' . $fileInfo->getPathname() . '".', 1169047619);
                    }
                } elseif (!$directoryIterator->isDot()) {
                    self::removeDirectoryRecursively($fileInfo->getPathname());
                }
            }
        }
    }
public static function emptyDirectoryRecursively(string $path)
    {
        if (!is_dir($path)) {
            throw new FilesException('"' . $path . '" is no directory.', 1169047616);
        }

        if (self::is_link($path)) {
            if (self::unlink($path) !== true) {
                throw new FilesException('Could not unlink symbolic link "' . $path . '".', 1323697654);
            }
        } else {
            $directoryIterator = new \RecursiveDirectoryIterator($path);
            foreach ($directoryIterator as $fileInfo) {
                if (!$fileInfo->isDir()) {
                    if (self::unlink($fileInfo->getPathname()) !== true) {
                        throw new FilesException('Could not unlink file "' . $fileInfo->getPathname() . '".', 1169047619);
                    }
                } elseif (!$directoryIterator->isDot()) {
                    self::removeDirectoryRecursively($fileInfo->getPathname());
                }
            }
        }
    }
public static function emptyDirectoryRecursively ( string $ path ) { if ( ! is_dir ( $ path ) ) { throw new FilesException ( '"' . $ path . '" is no directory.' , 1169047616 ) ; } if ( self :: is_link ( $ path ) ) { if ( self :: unlink ( $ path ) !== true ) { throw new FilesException ( 'Could not unlink symbolic link "' . $ path . '".' , 1323697654 ) ; } } else { $ directoryIterator = new \ RecursiveDirectoryIterator ( $ path ) ; foreach ( $ directoryIterator as $ fileInfo ) { if ( ! $ fileInfo -> isDir ( ) ) { if ( self :: unlink ( $ fileInfo -> getPathname ( ) ) !== true ) { throw new FilesException ( 'Could not unlink file "' . $ fileInfo -> getPathname ( ) . '".' , 1169047619 ) ; } } elseif ( ! $ directoryIterator -> isDot ( ) ) { self :: removeDirectoryRecursively ( $ fileInfo -> getPathname ( ) ) ; } } } }
Deletes all files, directories and subdirectories from the specified
directory. The passed directory itself won't be deleted though.

@param string $path Path to the directory which shall be emptied.
@return void
@throws FilesException
@see removeDirectoryRecursively()
@api
Deletes all files directories and subdirectories from the specified directory . The passed directory itself won t be deleted though .