private Response doRequest(Request req) throws IOException { return request(req).retrieve(getTimeoutMs(), TimeUnit.MILLISECONDS); }
@Override public void close() throws IOException { log.debug("Closing `{}`", this); requester.request(newRequest(PacketType.CLOSE)) .retrieve(requester.getTimeoutMs(), TimeUnit.MILLISECONDS) .ensureStatusPacketIsOK(); }
protected Promise<Response, SFTPException> asyncWrite(long fileOffset, byte[] data, int off, int len) throws IOException { return requester.request(newRequest(PacketType.WRITE) .putUInt64(fileOffset) .putString(data, off, len) ); }
protected Promise<Response, SFTPException> asyncRead(long fileOffset, int len) throws IOException { return requester.request(newRequest(PacketType.READ).putUInt64(fileOffset).putUInt32(len)); }
public FileAttributes fetchAttributes() throws IOException { return requester.request(newRequest(PacketType.FSTAT)) .retrieve(requester.getTimeoutMs(), TimeUnit.MILLISECONDS) .ensurePacketTypeIs(PacketType.ATTRS) .readFileAttributes(); }
public void setAttributes(FileAttributes attrs) throws IOException { requester.request(newRequest(PacketType.FSETSTAT).putFileAttributes(attrs)) .retrieve(requester.getTimeoutMs(), TimeUnit.MILLISECONDS).ensureStatusPacketIsOK(); }
final Response res = requester.request(newRequest(PacketType.READDIR)) .retrieve(requester.getTimeoutMs(), TimeUnit.MILLISECONDS); switch (res.getType()) {
private Response doRequest(Request req) throws IOException { return request(req).retrieve(getTimeoutMs(), TimeUnit.MILLISECONDS); }
private Response doRequest(Request req) throws IOException { return request(req).retrieve(getTimeoutMs(), TimeUnit.MILLISECONDS); }
@Override public Promise<Response, SFTPException> request(final Request req) throws IOException { log(Type.request, String.format("%d %s", req.getRequestID(), req.getType())); return super.request(req); } }.init();
protected Promise<Response, SFTPException> asyncWrite(long fileOffset, byte[] data, int off, int len) throws IOException { return requester.request(newRequest(PacketType.WRITE) .putUInt64(fileOffset) .putString(data, off, len) ); }
@Override public void close() throws IOException { log.debug("Closing `{}`", this); requester.request(newRequest(PacketType.CLOSE)) .retrieve(requester.getTimeoutMs(), TimeUnit.MILLISECONDS) .ensureStatusPacketIsOK(); }
protected Promise<Response, SFTPException> asyncRead(long fileOffset, int len) throws IOException { return requester.request(newRequest(PacketType.READ).putUInt64(fileOffset).putUInt32(len)); }
public FileAttributes fetchAttributes() throws IOException { return requester.request(newRequest(PacketType.FSTAT)) .retrieve(requester.getTimeoutMs(), TimeUnit.MILLISECONDS) .ensurePacketTypeIs(PacketType.ATTRS) .readFileAttributes(); }
public void setAttributes(FileAttributes attrs) throws IOException { requester.request(newRequest(PacketType.FSETSTAT).putFileAttributes(attrs)) .retrieve(requester.getTimeoutMs(), TimeUnit.MILLISECONDS).ensureStatusPacketIsOK(); }
final Response res = requester.request(newRequest(PacketType.READDIR)) .retrieve(requester.getTimeoutMs(), TimeUnit.MILLISECONDS); switch (res.getType()) {
private Space getSpaceAvailable(SFTPEngine sftp, final Path directory) throws BackgroundException { try { final Request request = sftp.newExtendedRequest("space-available").putString(directory.getAbsolute()); final Response response = sftp.request(request).retrieve(); switch(response.getType()) { case EXTENDED_REPLY:
private Space getSpaceStatVFSOpenSSH(SFTPEngine sftp, final Path directory) throws BackgroundException { try { final Request request = sftp.newExtendedRequest("statvfs@openssh.com").putString(directory.getAbsolute()); final Response response = sftp.request(request).retrieve(); switch(response.getType()) { case EXTENDED_REPLY: long blockSize = response.readUInt64(); /* file system block size */ long filesystemBlockSize = response.readUInt64(); /* fundamental fs block size */ long totalBlocks = response.readUInt64(); /* number of blocks (unit f_frsize) */ long filesystemFreeBlocks = response.readUInt64(); /* free blocks in file system */ long blocksAvailable = response.readUInt64(); /* free blocks for non-root */ long fileInodes = response.readUInt64(); /* total file inodes */ long fileInodesFree = response.readUInt64(); /* free file inodes */ long fileInodesAvailable = response.readUInt64(); /* free file inodes for to non-root */ byte[] filesystemID = new byte[8]; /* file system id */ response.readRawBytes(filesystemID); long flags = response.readUInt64(); /* bit mask of f_flag values */ long maximumFilenameLength = response.readUInt64(); /* maximum filename length */ long total = totalBlocks * filesystemBlockSize; long available = blocksAvailable * filesystemBlockSize; long used = total - available; return new Space(used, available); default: throw new IOException(String.format("Unexpected response type %s", response.getType())); } } catch(IOException e) { throw new SFTPExceptionMappingService().map("Failure to read attributes of {0}", e, directory); } }