Removes files and folders recursively at provided path.

@param string $path
16927
private static function rmdirRecursive($path)
    {
        $files = scandir($path);
        array_shift($files);
        array_shift($files);

        foreach ($files as $file) {
            $file = $path.DIRECTORY_SEPARATOR.$file;
            if (is_dir($file)) {
                self::rmdirRecursive($file);
            } else {
                unlink($file);
            }
        }

        rmdir($path);
    }
1035392
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);
            }
        }
    }
1012002
public function deleteFolderRecursively($folderPath)
    {
        $this->throwIfOperationNotInBaseFolder($folderPath);

        $itemIterator = new \RecursiveIteratorIterator(
            new \RecursiveDirectoryIterator($folderPath, \RecursiveDirectoryIterator::SKIP_DOTS),
            \RecursiveIteratorIterator::CHILD_FIRST
        );

        foreach ($itemIterator as $item) {
            if ($item->isDir()) {
                rmdir($item->getPathname());
            } else {
                unlink($item->getPathname());
            }
        }

        rmdir($folderPath);
    }
390482
public function resetPath(string $path)
    {
        foreach ($this->cache as &$cache) {
            unset($cache[$path], $cache);
        }
    }
72622
public function disallowDirectory($path)
	{
		if (is_array($path))
			foreach ($path as $dir)
				unset($this->allowedDirectories[realpath($dir)]);
		else
			unset($this->allowedDirectories[realpath($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;
    }
142260
private static function rmdir($path) {
        foreach (glob($path . '/*') as $file) {
            if (is_dir($file)) {
                self::rmdir($file);
            } else {
                unlink($file);
            }
        }

        // Remove the remaining directory
        rmdir($path);
    }
835603
public function amInPath($path)
    {
        chdir($this->path = $this->absolutizePath($path) . DIRECTORY_SEPARATOR);
        $this->debug('Moved to ' . getcwd());
    }
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);
		}
	}
732389
public static function remove($path)
    {
        $path = self::resolve($path);

        return $path && is_file($path) && unlink($path);
    }
857573
public static function deleteFolder($path) 
	{
		if(file_exists($path)) {
			$fh = dir($path);
			//print_r($fh);
			while (false !== ($files = $fh->read())) {
				/*
				echo $fh->path.'/'.$files."\n";
				chmod($fh->path.'/'.$files, 0755);
				if(@unlink($fh->path.'/'.$files))
					echo '1'."\n";
				else
					echo '0'."\n";
				*/
				@unlink($fh->path.'/'.$files);
			}
			$fh->close();
			@rmdir($path);

			return true;

		} else 
			return false;
	}
713751
public static function recursive($path)
    {
        if (is_dir($path)) {
            $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::CHILD_FIRST);
            foreach ($iterator as $file) {
                self::_deleteFile($file);
            }
            rmdir($path);
        }
    }
658194
protected function deleteRecursive($path)
    {
        if (is_file($path) || is_link($path)) {
            return unlink($path);
        }
        $success = true;
        $dir = dir($path);
        while (($entry = $dir->read()) !== false) {
            if ($entry == '.' || $entry == '..') {
                continue;
            }
            $entry_path = $path . '/' . $entry;
            $success = static::deleteRecursive($entry_path) && $success;
        }
        $dir->close();

        return rmdir($path) && $success;
    }
711059
public function deleteRecursive($path)
	{
		if (!$this->tryDelete($path)) {
			foreach ((array) $this->nlist($path) as $file) {
				if ($file !== '.' && $file !== '..') {
					$this->deleteRecursive(strpos($file, '/') === FALSE ? "$path/$file" : $file);
				}
			}
			$this->rmdir($path);
		}
	}
1047858
public static function deleteDir($path) {

        $dir = opendir($path);
        while (false !== ($file = readdir($dir))) {
            if (($file != '.') && ($file != '..')) {
                $full = $path . '/' . $file;
                if (is_dir($full)) {
                    self::deleteDir($full);
                } else {
                    unlink($full);
                }
            }
        }
        closedir($dir);
        rmdir($path);
    }
236747
public function remove($path)
    {
        StructureHelper::removeByPath($this->data, $path, $this->separator);

        return $this;
    }
1322698
public function delete($path)
  {
    if (is_link($path)) {
      $this->_deleteSymlink($path);
    } elseif (is_file($path)) {
      unlink($path);
    } else {
      $iteratorRd = new RecursiveDirectoryIterator($path);
      $iteratorRi = new RecursiveIteratorIterator(
        $iteratorRd, RecursiveIteratorIterator::CHILD_FIRST
      );
      foreach ($iteratorRi as $file) {
        /* @var $file \SplFileInfo */
        $filename = $file->getPathname();
        if ($file->isLink()) {
          $this->_deleteSymlink($filename);
        } elseif ($file->isDir()) {
          if (substr($filename, -1, 1) != ".") {
            rmdir($filename);
          }
        } else {
          unlink($filename);
        }
      }
      rmdir($path);
    }
  }