Removes the files recursively from the specified directory.

@param  string $path
@return void
172063
protected function clear($path)
    {
        $directory = new \RecursiveDirectoryIterator($path, 4096);

        $iterator = new \RecursiveIteratorIterator($directory, 2);

        foreach ($iterator as $file) {
            $git = strpos($file->getRealPath(), '.git') !== false;

            $path = (string) $file->getRealPath();

            $git || ($file->isDir() ? rmdir($path) : unlink($path));
        }
    }
430331
protected function clearDir($path)
    {
        $items = [];
        $finder = new Finder();
        $finder->in($path)
            ->ignoreVCS(false)
            ->ignoreDotFiles(false);

        foreach ($finder as $item) {
            $items[] = $item->getRealpath();
        }

        if (count($items) > 0) {
            $this->fs->remove($items);
        }
    }
1293813
private function deleteFiles(Directory $path)
    {
        foreach ($this->manager->findFiles($path) as $file) {
            $this->wrapper->delete($file->getRealpath());
        }
    }
1180577
private function cleanEmptyArraysInPath($path)
    {
        $subs = $this->getEntries($path);
        if (!empty($subs)) {
            foreach ($subs as $subPath) {
                $this->cleanEmptyArraysInPath($subPath);
            }
        }

        if ([] === $this->get($path)) {
            $this->remove($path);
        }
    }
66737
public static function emptyDirRecursive($dirPath)
    {
        foreach (
            new RecursiveIteratorIterator(
                new RecursiveDirectoryIterator($dirPath, FilesystemIterator::SKIP_DOTS),
                RecursiveIteratorIterator::CHILD_FIRST
            ) as $path
        ) {
            if ($path->isFile()) {
                unlink($path->getPathname());
            } else {
                rmdir($path->getPathname());
            }
        }
    }
1212457
public static function remove($path)
    {
        $path = Normalize::diskFullPath($path);

        if (!self::exist($path)) {
            return false;
        }
        return unlink($path);
    }
72622
public function disallowDirectory($path)
	{
		if (is_array($path))
			foreach ($path as $dir)
				unset($this->allowedDirectories[realpath($dir)]);
		else
			unset($this->allowedDirectories[realpath($path)]);
	}
932197
public static function deleteDir($path)
    {
        if (!is_dir($path)) return;

        $path = rtrim($path, '/') . '/';

        $dir_obj = opendir($path);

        while ($dir = readdir($dir_obj)) {
            if ($dir != '.' && $dir != '..') {
                $file = $path . $dir;
                if (is_dir($file)) {
                    self::deleteDir($file);
                } elseif (is_file($file)) {
                    unlink($file);
                }

            }
        }
        closedir($dir_obj);
        rmdir($path);
    }
1057343
protected function tearDown()
    {
        foreach ($this->purgePaths as $path) {
            if (file_exists($path)) {
                $this->purgePath($path);
            }
        }
    }
1097420
public static function removeDirectory($path) {
        if (is_dir($path))
            $dir = opendir($path);
        if (!$dir)
            return false;
        while ($file = readdir($dir))
            if (!self::isDot($file)) {
	            if (!is_dir("$path/$file"))
                    unlink("$path/$file");
	            else
                    self::removeDirectory("$path/$file");
            }
        closedir($dir);
        rmdir($path);
        return true;
    }
1216547
public static function delete( $path ) {
		if ( !is_dir( $path ) ) { // already deleted
			return;
		}
		$files = scandir( $path );
		if ( !$files ) {
			throw new GpgLibException( "Tried to delete temporary directory $path but could not find it" );
		}
		foreach ( $files as $file ) {
			if ( $file === '.' || $file === '..' ) {
				continue;
			}
			$file = $path . DIRECTORY_SEPARATOR . $file;
			$ok = unlink( $file );
			if ( !$ok ) {
				throw new GpgLibException( "Could not delete $file" );
			}
		}
		$ok = rmdir( $path );
		if ( !$ok ) {
			throw new GpgLibException( "Could not delete $path" );
		}
	}
169881
public function remove(array $path)
    {
        $current    = &$this->hierarchy;
        $pathLength = count($path);
        for ($i = 0; $i < $pathLength; $i++) {
            if (!isset($current[$path[$i]])) {
                break;
            }
            if ($i === $pathLength - 1) {
                unset($current[$path[$i]]);
                break;
            }
            $current = &$current[$path[$i]];
        }
    }
925864
static public function emptyDir($dirpath)
    {
        foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dirpath, FilesystemIterator::SKIP_DOTS), RecursiveIteratorIterator::CHILD_FIRST) as $path) {
            $path->isFile() ? unlink($path->getPathname()) : rmdir($path->getPathname());
        }
    }
1147421
public function purge($dir)
    {
        if (!is_dir($dir)) {
            return;
        }

        $files = scandir($dir);

        if ($files !== false) {
            foreach ($files as $file) {
                if ($file === '.' || $file === '..') {
                    continue;
                }

                $path = $dir . '/' . $file;

                if (is_dir($path)) {
                    $this->purge($path);
                    rmdir($path);
                } else {
                    unlink($path);
                }
            }
        }
    }
1066299
private function ensureDirectoryExists($path)
    {
        if (array_key_exists($path, $this->json)) {
            return;
        }

        // Recursively initialize parent directories
        if ('/' !== $path) {
            $this->ensureDirectoryExists(Path::getDirectory($path));
        }

        $this->json[$path] = null;
    }
1188128
public function delete($path)
    {
        $paths = is_array($path) ? $path : func_get_args();

        $success = true;

        foreach ($paths as $path) {

            if ($this->isDirectory($path)) {
                $success = $this->laravelFS->deleteDirectory($path);
                continue;
            }
            $success = $this->laravelFS->delete($path);

        }

        return $success;
    }
407682
public function removePath($path, $clearCache = true, $group = '__DEFAULT__')
	{
		$path = $this->normalizePath($path);

		if ($path and isset($this->paths[$group][$path]))
		{
			unset($this->paths[$group][$path]);

			if ($clearCache) $this->removePathCache($path);
		}
	}