Delete.

@param string $path
@param bool $preserveRoot Default false.
@return bool
774736
public static function delete(?string $path, bool $preserveRoot = false): bool
    {
        // Ensure that we are not doing something stupid.
        if (!is_string($path) || trim($path) === '' || trim($path) === '/') {
            return false;
        }

        if (!self::isDirectory($path)) {
            return false;
        }

        // Loop through entries.
        $entries = self::entries($path, '*', [], true);
        foreach ($entries as $entry) {
            $filename = $entry['path'] . '/' . $entry['name'];
            if ($entry['type'] === self::TYPE_DIRECTORY) {
                self::delete($filename);
                @rmdir($filename);
            } elseif ($entry['type'] === self::TYPE_LINK) {
                File::delete($filename);
            } elseif ($entry['type'] === self::TYPE_FILE) {
                File::delete($filename);
            }
        }

        // Remote root.
        if (!$preserveRoot) {
            @rmdir($path);
        }

        return true;
    }
1303796
public function delete($path)
    {
        $result = $this->client->deleteObject([
            'Bucket' => $this->getBucket(),
            'Key'    => $path,
        ]);

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

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

        return true;
    }
622441
public function move($path, $toPath, $deleteOriginal = true)
    {
        if (copy($path, $toPath)) {
            if ($deleteOriginal) {
                if (!$this->remove($path)) {
                    //@todo say you could not delete the original
                }
            }

            return true;
        }

        return false;
    }
1336945
public function deleteDir($path)
    {
        $this->deleteContents($path);

        $location = $this->applyPathPrefix($path);

        try {
            $this->share->rmdir($location);
        } catch (NotFoundException $e) {
            return false;
        } catch (InvalidTypeException $e) {
            return false;
        }

        return true;
    }
1312714
public function delete($path, $callback)
    {
        Argument::i()
            //argument 1 should be a string
            ->test(1, 'string')
            //argument 2 should be callable
            ->test(2, 'callable');
        
        return $this->route('delete', $path, $callback);
    }
1323278
public function remove($path)
    {
        if (! $this->adapter->isAbsolute($path)) {
            $path = $this->rootPath . $path;
        }
        if ($this->isFile($path, true)) {
            $this->adapter->unlink($path);
        } else {
            // clean the directory
            $path = rtrim($path, '/') . '/';
            foreach ($this->adapter->glob($path . '*') as $itemPath) {
                $this->remove($itemPath, true);
            }
            // remove it
            $this->adapter->rmdir($path);
        }
        return $this;
    }
1010911
public function deleteFile($path)
    {
        $path = $this->cleanFolder($path);
        if (!$this->disk->exists($path)) {
            $this->errors[] = 'File does not exist.';

            return false;
        }

        return $this->disk->delete($path);
    }
493295
public static function recursiveDelete($path) {
		if(is_file($path)) {
			@unlink($path);

		} else {
			$it = new RecursiveIteratorIterator(
				new RecursiveDirectoryIterator($path),
				RecursiveIteratorIterator::CHILD_FIRST
			);

			foreach ($it as $file) {
				if (in_array($file->getBasename(), array('.', '..'))) {
					continue;
				}elseif ($file->isDir()) {
					rmdir($file->getPathname());
				}elseif ($file->isFile() || $file->isLink()) {
					unlink($file->getPathname());
				}
			}
			rmdir($path);
		}

		return false;
	}
1081794
public function remove( $path )
    {
        if ( null === $this->identity )
        {
            return false;
        }

        if ( is_array( $path ) || is_object( $path ) )
        {
            $result = array();

            foreach ( $path as $key => $p )
            {
                $result[$key] = $this->remove( $p );
            }

            return $result;
        }

        $path = $this->realPath( $path );
        $base = $this->baseUrl . ( empty( $path ) ? '' : '/' . $path );
        $full = realpath( $this->baseDir . '/' . $base );

        if ( empty( $path ) ) // prevent delete root
        {
            return false;
        }

        $isDir  = is_dir( $full );
        $isFile = is_file( $full );

        if ( $isDir || $isFile )
        {
            $rights = $this->rights( $path );

            if ( $rights->delete )
            {
                switch ( true )
                {
                    case $isDir:
                        return $this->_rmdir( $full );

                    case $isFile:
                        return @ unlink( $full );
                }
            }
        }

        return false;
    }
360286
public function deletePath($path = '', $public = true)
    {
        $path = $this->getStoragePath($path);

        return $this->_storage->delete($path, $public);
    }
996967
public static function delete($path)
  {
    if (is_file($path)) {
      return unlink($path);
    }

    $files = array_diff(scandir($path), array('.', '..'));

    foreach ($files as $file) {
      (is_dir("$path/$file")) ? Filesystem::delete("$path/$file") : unlink("$path/$file");
    }

    return rmdir($path);
  }
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;
    }
653924
public function delete($path)
    {
        $path = realpath($path);
        if (strpos($path, $this->getDefaultPath()) === 0) {
            if (is_dir($path)) {
                foreach (glob($path . '/*') as $file) {
                    $this->delete($path);
                }
                return @rmdir($path);
            } else {
                return @unlink($path);
            }
        } else {
            throw new \InvalidArgumentException("Path not allowed '$path'");
        }
    }
981173
public function delete($path): bool
    {
        $result = false;
        $parts = $this->split($path);

        $name = array_shift($parts);
        if (!count($parts)) {
            if (isset($this->ownData[$name])) {
                unset($this->ownData[$name]);
                $result = true;
            }
        } elseif (isset($this->subTrees[$name])) {
            $subtree = $this->subTrees[$name];
            $result = $subtree->delete($parts);
            if ($result && !$subtree->count()) {
                unset($this->subTrees[$name]);
            }
        }

        return $result;
    }
208067
public function deleteNode($path)
	 {
	 	if(!$this->zookeeper->exists($path))
	 	{
	 		return null;
	 	}
	 	else
	 	{
	 		return $this->zookeeper->delete($path);
	 	}
	 }
108465
final public function delete($path)
    {

        //If we have permission to remove this file
        if ($this->isWritable($path)) {
            if (!@unlink($path)) //This is highly unreliable as unlink returns a warning not a bool
            {
                return false;
            }
        } else {
            if (!@unlink($path)) //This is highly unreliable as unlink returns a warning not a bool
            {
                return false;
            }
        }

        return true;
    }