use of com.trilead.ssh2.SFTPv3Client in project intellij-community by JetBrains.
the class SFTPv3Client method canonicalPath.
/**
* Have the server canonicalize any given path name to an absolute path.
* This is useful for converting path names containing ".." components or
* relative pathnames without a leading slash into absolute paths.
*
* @param path See the {@link SFTPv3Client comment} for the class for more details.
* @return An absolute path.
* @throws IOException
*/
public String canonicalPath(String path) throws IOException {
int req_id = generateNextRequestID();
TypesWriter tw = new TypesWriter();
tw.writeString(path, charsetName);
if (debug != null) {
debug.println("Sending SSH_FXP_REALPATH...");
debug.flush();
}
sendMessage(Packet.SSH_FXP_REALPATH, req_id, tw.getBytes());
byte[] resp = receiveMessage(34000);
if (debug != null) {
debug.println("Got REPLY.");
debug.flush();
}
TypesReader tr = new TypesReader(resp);
int t = tr.readByte();
int rep_id = tr.readUINT32();
if (rep_id != req_id)
throw new IOException("The server sent an invalid id field.");
if (t == Packet.SSH_FXP_NAME) {
int count = tr.readUINT32();
if (count != 1)
throw new IOException("The server sent an invalid SSH_FXP_NAME packet.");
return tr.readString(charsetName);
}
if (t != Packet.SSH_FXP_STATUS)
throw new IOException("The SFTP server sent an unexpected packet type (" + t + ")");
int errorCode = tr.readUINT32();
throw new SFTPException(tr.readString(), errorCode);
}
use of com.trilead.ssh2.SFTPv3Client in project intellij-community by JetBrains.
the class SFTPv3Client method rm.
/**
* Remove a file.
*
* @param fileName See the {@link SFTPv3Client comment} for the class for more details.
* @throws IOException
*/
public void rm(String fileName) throws IOException {
int req_id = generateNextRequestID();
TypesWriter tw = new TypesWriter();
tw.writeString(fileName, charsetName);
sendMessage(Packet.SSH_FXP_REMOVE, req_id, tw.getBytes());
expectStatusOKMessage(req_id);
}
use of com.trilead.ssh2.SFTPv3Client in project intellij-community by JetBrains.
the class SFTPv3Client method rmdir.
/**
* Remove an empty directory.
*
* @param dirName See the {@link SFTPv3Client comment} for the class for more details.
* @throws IOException
*/
public void rmdir(String dirName) throws IOException {
int req_id = generateNextRequestID();
TypesWriter tw = new TypesWriter();
tw.writeString(dirName, charsetName);
sendMessage(Packet.SSH_FXP_RMDIR, req_id, tw.getBytes());
expectStatusOKMessage(req_id);
}
use of com.trilead.ssh2.SFTPv3Client in project intellij-community by JetBrains.
the class SFTPv3Client method mkdir.
/**
* Create a new directory.
*
* @param dirName See the {@link SFTPv3Client comment} for the class for more details.
* @param posixPermissions the permissions for this directory, e.g., "0700" (remember that
* this is octal noation). The server will likely apply a umask.
*
* @throws IOException
*/
public void mkdir(String dirName, int posixPermissions) throws IOException {
int req_id = generateNextRequestID();
TypesWriter tw = new TypesWriter();
tw.writeString(dirName, charsetName);
tw.writeUINT32(AttribFlags.SSH_FILEXFER_ATTR_PERMISSIONS);
tw.writeUINT32(posixPermissions);
sendMessage(Packet.SSH_FXP_MKDIR, req_id, tw.getBytes());
expectStatusOKMessage(req_id);
}
use of com.trilead.ssh2.SFTPv3Client in project intellij-community by JetBrains.
the class SFTPv3Client method mv.
/**
* Move a file or directory.
*
* @param oldPath See the {@link SFTPv3Client comment} for the class for more details.
* @param newPath See the {@link SFTPv3Client comment} for the class for more details.
* @throws IOException
*/
public void mv(String oldPath, String newPath) throws IOException {
int req_id = generateNextRequestID();
TypesWriter tw = new TypesWriter();
tw.writeString(oldPath, charsetName);
tw.writeString(newPath, charsetName);
sendMessage(Packet.SSH_FXP_RENAME, req_id, tw.getBytes());
expectStatusOKMessage(req_id);
}
Aggregations