<p>
Remove a file or directory from the remote computer.
</p>

@param path
the path of the remote file/directory

@throws SftpStatusException
@throws SshException
196479
public void rm(String path) throws SftpStatusException, SshException {
		String actual = resolveRemotePath(path);

		SftpFileAttributes attrs = sftp.getAttributes(actual);
		if (attrs.isDirectory()) {
			sftp.removeDirectory(actual);
		} else {
			sftp.removeFile(actual);
		}
	}
922839
public void remove(SshPublicKey key) throws SshException,
			PublicKeySubsystemException {

		try {

			Packet msg = createPacket();
			msg.writeString("remove");
			msg.writeString(key.getAlgorithm());
			msg.writeBinaryString(key.getEncoded());

			sendMessage(msg);

			readStatusResponse();

		} catch (IOException ex) {
			throw new SshException(ex);
		}
	}
1152117
public static void delete(String path) throws IOException {
    if (!Files.deleteIfExists(Paths.get(path))) {
      throw new IOException("Failed to delete " + path);
    }
  }
1200948
protected void removeIndexBackup(String path) {

        if (!isBackupReindexing()) {
            // if no backup is generated we don't need to do anything
            return;
        }

        // check if the target directory already exists
        File file = new File(path);
        if (!file.exists()) {
            // index does not exist yet
            return;
        }
        try {
            FSDirectory dir = FSDirectory.open(file.toPath());
            dir.close();
            CmsFileUtil.purgeDirectory(file);
        } catch (Exception e) {
            LOG.error(Messages.get().getBundle().key(Messages.LOG_IO_INDEX_BACKUP_REMOVE_2, getName(), path), e);
        }
    }
1176297
public void removeFile(String filename) throws SftpStatusException,
			SshException {
		try {
			UnsignedInteger32 requestId = nextRequestId();
			Packet msg = createPacket();
			msg.write(SSH_FXP_REMOVE);
			msg.writeInt(requestId.longValue());
			msg.writeString(filename, CHARSET_ENCODING);

			sendMessage(msg);

			getOKRequestStatus(requestId);
		} catch (SshIOException ex) {
			throw ex.getRealException();
		} catch (IOException ex) {
			throw new SshException(ex);
		}
		EventServiceImplementation.getInstance()
				.fireEvent(
						(new Event(this,
								J2SSHEventCodes.EVENT_SFTP_FILE_DELETED, true))
								.addAttribute(
										J2SSHEventCodes.ATTRIBUTE_FILE_NAME,
										filename));
	}
993955
public void delete(String fromPath, String toPath, Status status) {
        http.delete(fromPath, redirectRoute(toPath, status));
    }
896627
public static void deleteFilePathOnExit(FilePath workspace, String path) throws IOException, InterruptedException {
        FilePath filePath = new FilePath(workspace, path);
        deleteFilePathOnExit(filePath);
    }
58590
public void writeToFile(String path) {
        try {
            try (OutputStream os = new FileOutputStream(path)) {
                InputStreams.transferTo(body(), os);
            }
        } catch (IOException e) {
            throw new RequestsException(e);
        } finally {
            close();
        }
    }
824353
public void setAttributes(String path, SftpFileAttributes attrs)
			throws SftpStatusException, SshException {
		try {
			UnsignedInteger32 requestId = nextRequestId();

			Packet msg = createPacket();
			msg.write(SSH_FXP_SETSTAT);
			msg.writeInt(requestId.longValue());
			msg.writeString(path, CHARSET_ENCODING);
			msg.write(attrs.toByteArray());

			sendMessage(msg);

			getOKRequestStatus(requestId);
		} catch (SshIOException ex) {
			throw ex.getRealException();
		} catch (IOException ex) {
			throw new SshException(ex, SshException.INTERNAL_ERROR);
		}
	}
731022
public SFTPv3FileAttributes _stat(String path) throws IOException {
        try {
            return stat(path);
        } catch (SFTPException e) {
            int c = e.getServerErrorCode();
            if (c==ErrorCodes.SSH_FX_NO_SUCH_FILE || c==ErrorCodes.SSH_FX_NO_SUCH_PATH)
                return null;
            else
                throw e;
        }
    }
529788
public void chgrp(String gid, String path) throws SftpStatusException,
			SshException {
		String actual = resolveRemotePath(path);

		SftpFileAttributes attrs = sftp.getAttributes(actual);
		attrs.setGID(gid);
		sftp.setAttributes(actual, attrs);

	}
870529
private static void deleteLocalPath(MRAsyncDiskService asyncDiskService,
      LocalFileSystem fs, Path path) throws IOException {
    boolean deleted = false;
    if (asyncDiskService != null) {
      // Try to delete using asyncDiskService
      String localPathToDelete =
        path.toUri().getPath();
      deleted = asyncDiskService.moveAndDeleteAbsolutePath(localPathToDelete);
      if (!deleted) {
        LOG.warn("Cannot find DistributedCache path " + localPathToDelete
            + " on any of the asyncDiskService volumes!");
      }
    }
    if (!deleted) {
      // If no asyncDiskService, we will delete the files synchronously
      fs.delete(path, true);
    }
    LOG.info("Deleted path " + path);
  }
338558
public void chmod(String path, int permissions) throws IOException {
        SFTPv3FileAttributes atts = new SFTPv3FileAttributes();
        atts.permissions = permissions;
        setstat(path, atts);
    }
238167
private void removeEsDirectoryRecursively(final String path) throws Exception {
        logger.debug("Delete folder [{}]", path);
        Collection<String> listFile = getFileDirectory(path);

        for (String esfile : listFile) {
            esDelete(fsSettings.getElasticsearch().getIndex(), SignTool.sign(path.concat(File.separator).concat(esfile)));
        }

        Collection<String> listFolder = getFolderDirectory(path);
        for (String esfolder : listFolder) {
            removeEsDirectoryRecursively(esfolder);
        }

        esDelete(fsSettings.getElasticsearch().getIndexFolder(), SignTool.sign(path));
    }
868333
public void rm(String path, boolean force, boolean recurse)
			throws SftpStatusException, SshException {
		String actual = resolveRemotePath(path);

		SftpFileAttributes attrs = null;

		attrs = sftp.getAttributes(actual);

		SftpFile file;

		if (attrs.isDirectory()) {
			SftpFile[] list = ls(path);

			if (!force && (list.length > 0)) {
				throw new SftpStatusException(
						SftpStatusException.SSH_FX_FAILURE,
						"You cannot delete non-empty directory, use force=true to overide");
			}
			for (int i = 0; i < list.length; i++) {
				file = list[i];

				if (file.isDirectory() && !file.getFilename().equals(".")
						&& !file.getFilename().equals("..")) {
					if (recurse) {
						rm(file.getAbsolutePath(), force, recurse);
					} else {
						throw new SftpStatusException(
								SftpStatusException.SSH_FX_FAILURE,
								"Directory has contents, cannot delete without recurse=true");
					}
				} else if (file.isFile()) {
					sftp.removeFile(file.getAbsolutePath());
				}
			}

			sftp.removeDirectory(actual);
		} else {
			sftp.removeFile(actual);
		}
	}
568714
public ConfigurationUpdate removePath(String path) {
		if (path == null || !path.startsWith("/")) {
			throw new IllegalArgumentException("Path must start with \"/\".");
		}
		paths.put(path, null);
		return this;
	}
940427
public void rename(String oldpath, String newpath)
			throws SftpStatusException, SshException {
		String from = resolveRemotePath(oldpath);
		String to = resolveRemotePath(newpath);

		SftpFileAttributes attrs = null;

		try {
			attrs = sftp.getAttributes(to);

		} catch (SftpStatusException ex) {
			sftp.renameFile(from, to);
			return;
		}

		if (attrs != null && attrs.isDirectory()) {
			sftp.renameFile(from, to);
		} else {
			throw new SftpStatusException(
					SftpStatusException.SSH_FX_FILE_ALREADY_EXISTS, newpath
							+ " already exists on the remote filesystem");
		}

	}