Remove file/ recursive remove dir

@param  string  $path   file path
@param  bool    $force  try to remove even if file locked
@return bool
@author Dmitry (dio) Levashov
176481
protected function remove($path, $force = false) {
		$stat = $this->stat($path);
		
		if (empty($stat)) {
			return $this->setError(elFinder::ERROR_RM, $this->path($path), elFinder::ERROR_FILE_NOT_FOUND);
		}
		
		$stat['realpath'] = $path;
		$this->rmTmb($stat);
		$this->clearcache();
		
		if (!$force && !empty($stat['locked'])) {
			return $this->setError(elFinder::ERROR_LOCKED, $this->path($path));
		}
		
		if ($stat['mime'] == 'directory') {
			$ret = $this->delTree($this->convEncIn($path));
			$this->convEncOut();
			if (!$ret) {
				return $this->setError(elFinder::ERROR_RM, $this->path($path));
			}
		} else {
			if ($this->convEncOut(!$this->_unlink($this->convEncIn($path)))) {
				return $this->setError(elFinder::ERROR_RM, $this->path($path));
			}
		}

		$this->removed[] = $stat;
		return true;
	}
28146
public function move( $folderPath, $force = FALSE )
	{
		if( !$this->moveFolder( $this->folderName, $folderPath, $force ) )
			return FALSE;
		$this->folderName	= $folderPath;
		return TRUE;
	}
1205304
public function unlink($path)
    {
        $container = $this->getContainerFromContext($path);

        try {

            $path = $this->stripScheme($path);

            $parent = $container->nodeAt(dirname($path));

            $permissionHelper = $container->getPermissionHelper($parent);
            if (!$permissionHelper->isWritable()) {
                trigger_error(
                    sprintf('rm: %s: Permission denied', $path),
                    E_USER_WARNING
                );

                return false;
            }

            $container->remove($path = $this->stripScheme($path));
        } catch (NotFoundException $e) {
            trigger_error(
                sprintf('rm: %s: No such file or directory', $path),
                E_USER_WARNING
            );

            return false;
        } catch (\RuntimeException $e) {
            trigger_error(
                sprintf('rm: %s: is a directory', $path),
                E_USER_WARNING
            );

            return false;
        }

        return true;
    }
1120892
public function remove($path)
    {
        $path = explode($this->separator, $path);
        $last = array_pop($path);

        $item = &$this->item;

        foreach ($path as $key) {
            if (array_key_exists($key, $item) && is_array($item[$key])) {
                $item = &$item[$key];
                continue;
            }
            return false;
        }
        
        if (array_key_exists($last, $item)) {
            unset($item[$last]);
            return true;
        }

        return false;
    }
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;
    }
876639
public function delete( $id, $force = false ) {

		$this->set_request_args( array(
			'method' => 'DELETE',
			'path'   => $id,
			'params' => array( 'force' => $force ),
		) );

		return $this->do_request();
	}
1085832
public static function remove($path, $recursive = false)
    {
        $path = \rtrim($path, '/') . '/';

        if ($recursive)
        {

            $storage = \array_merge(
                \glob($path . '*'),
                \glob($path . '.*')
            );

            foreach ($storage as $item)
            {

                if (in_array(basename($item), ['.', '..'], true))
                {
                    continue;
                }

                if (static::isDir($item))
                {
                    static::remove($item, $recursive);
                    continue;
                }

                File::remove($item);

            }

        }

        return rmdir($path);
    }
554761
public function remove( $path, $write = false )
	{
		$result	= $this->removeRecursive( $path, $this->storage );
		if( $write && $result )
			return (bool) $this->write();
		return $result;
	}
1264246
public static function delete($path)
    {
        @set_time_limit((int) ini_get('max_execution_time'));

        // Sanity check
        if (!rtrim($path, '/\\')) {
            // Bad programmer! Bad Bad programmer!
            throw new FilesystemException(__METHOD__ . ': You can not delete a base directory.');
        }

        // Check to make sure the path valid and clean
        $path = Path::clean($path);

        // Is this really a folder?
        if (!is_dir($path)) {
            throw new \UnexpectedValueException(sprintf('%1$s: Path is not a folder. Path: %2$s', __METHOD__, $path));
        }

        // Remove all the files in folder if they exist; disable all filtering
        $files = static::files($path);

        if (!empty($files)) {
            File::delete($files);
        }

        // Remove sub-folders of folder; disable all filtering
        $folders = static::items($path);

        foreach ($folders as $folder) {
            if (is_link($folder)) {
                // Don't descend into linked directories, just delete the link.
                File::delete($folder);
            } elseif (is_dir($folder)) {
                static::delete($folder);
            }
        }

        // In case of restricted permissions we zap it one way or the other
        // as long as the owner is either the webserver or the ftp.
        if (@rmdir($path)) {
            return true;
        } else {
            $error = error_get_last();
            throw new FilesystemException($error['message'], $error['type']);
        }
    }
499874
public function removeDirectory(string $path): bool
	{
		foreach(new FilesystemIterator($path) as $item)
		{
			if($item->isDir())
			{
				$this->removeDirectory($item->getPathname());
			}
			else
			{
				unlink($item->getPathname());
			}
		}

		return rmdir($path);
	}
179590
public static function delete($path)
	{
		if (is_dir($path)) {
			Dir::delete($path);
		} elseif (is_file($path)) {
			File::delete($path);
		}

		return true;
	}
1058389
public static function unlink($path): bool
    {
        $isWindows = DIRECTORY_SEPARATOR === '\\';

        if (!$isWindows) {
            return unlink($path);
        }

        if (is_link($path) && is_dir($path)) {
            return rmdir($path);
        }

        return unlink($path);
    }
1261229
public function unlink($path)
    {
        if (false === self::cache()->get($path)) {
            return false;
        }

        self::cache()->delete($path);

        return true;
    }
321333
public static function rmdir( $dirPath, $force = false )
    {
        $_path = rtrim( $dirPath ) . DIRECTORY_SEPARATOR;

        if ( !$force )
        {
            return rmdir( $_path );
        }

        if ( !is_dir( $_path ) )
        {
            throw new \InvalidArgumentException( '"' . $_path . '" is not a directory or bogus in some other way.' );
        }

        $_files = glob( $_path . '*', GLOB_MARK );

        foreach ( $_files as $_file )
        {
            if ( is_dir( $_file ) )
            {
                static::rmdir( $_file, true );
            }
            else
            {
                unlink( $_file );
            }
        }

        return rmdir( $_path );
    }
624233
public function unlink($path)
    {
        $stream = $this->createStream($path);

        try {
            $stream->open($this->createStreamMode('w+'));
        } catch (\RuntimeException $e) {
            return false;
        }

        return $stream->unlink();
    }
970433
public function deleteFolder($container, $path, $force = false, $content_only = false)
    {
        $dir = static::addContainerToName($container, $path);
        FileUtilities::deleteTree($dir, $force, !$content_only);
    }
205537
public function recursiveRemoveDirectory($path)
    {
        $files = new RecursiveIteratorIterator(
            new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::SKIP_DOTS),
            RecursiveIteratorIterator::CHILD_FIRST
        );
        foreach ($files as $file) {
            if ($file->isDir()) {
                self::removeDirectory($file->getRealPath());
            } else {
                self::unlink($file->getRealPath());
            }
        }
        self::removeDirectory($path);
    }