@Override public Promise<Response, SFTPException> request(Request req) throws IOException { final Promise<Response, SFTPException> promise = reader.expectResponseTo(req.getRequestID()); log.debug("Sending {}", req); transmit(req); return promise; }
protected Request newRequest(PacketType type) { return requester.newRequest(type).putString(handle); }
@Override public synchronized Request newRequest(PacketType type) { return new Request(type, reqID = reqID + 1 & 0xffffffffL); }
public void setAttributes(String path, FileAttributes attrs) throws IOException { doRequest( newRequest(PacketType.SETSTAT).putString(path, sub.getRemoteCharset()).putFileAttributes(attrs) ).ensureStatusPacketIsOK(); }
public RemoteFile open(String path, Set<OpenMode> modes, FileAttributes fa) throws IOException { final byte[] handle = doRequest( newRequest(PacketType.OPEN).putString(path, sub.getRemoteCharset()).putUInt32(OpenMode.toMask(modes)).putFileAttributes(fa) ).ensurePacketTypeIs(PacketType.HANDLE).readBytes(); return new RemoteFile(this, path, handle); }
protected Promise<Response, SFTPException> asyncWrite(long fileOffset, byte[] data, int off, int len) throws IOException { return requester.request(newRequest(PacketType.WRITE) .putUInt64(fileOffset) .putUInt32(len - off) .putRawBytes(data, off, len) ); }
@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();
public Request(PacketType type, long reqID) { super(type); this.type = type; this.reqID = reqID; putUInt32(reqID); }
public void setAttributes(FileAttributes attrs) throws IOException { requester.request(newRequest(PacketType.FSETSTAT).putFileAttributes(attrs)) .retrieve(requester.getTimeoutMs(), TimeUnit.MILLISECONDS).ensureStatusPacketIsOK(); }
public RemoteFile open(String path, Set<OpenMode> modes, FileAttributes fa) throws IOException { final String handle = doRequest( newRequest(PacketType.OPEN).putString(path).putUInt32(OpenMode.toMask(modes)).putFileAttributes(fa) ).ensurePacketTypeIs(PacketType.HANDLE).readString(); return new RemoteFile(this, path, handle); }
public void makeDir(String path, FileAttributes attrs) throws IOException { doRequest(newRequest(PacketType.MKDIR).putString(path, sub.getRemoteCharset()).putFileAttributes(attrs)).ensureStatusPacketIsOK(); }
public Request(PacketType type, long reqID) { super(type); this.type = type; this.reqID = reqID; putUInt32(reqID); }
public void setAttributes(FileAttributes attrs) throws IOException { requester.request(newRequest(PacketType.FSETSTAT).putFileAttributes(attrs)) .retrieve(requester.getTimeoutMs(), TimeUnit.MILLISECONDS).ensureStatusPacketIsOK(); }
public Request newExtendedRequest(String reqName) { return newRequest(PacketType.EXTENDED).putString(reqName); }
public RemoteFile open(String path, Set<OpenMode> modes, FileAttributes fa) throws IOException { final byte[] handle = doRequest( newRequest(PacketType.OPEN).putString(path, sub.getRemoteCharset()).putUInt32(OpenMode.toMask(modes)).putFileAttributes(fa) ).ensurePacketTypeIs(PacketType.HANDLE).readBytes(); return new RemoteFile(this, path, handle); }
public void setAttributes(String path, FileAttributes attrs) throws IOException { doRequest( newRequest(PacketType.SETSTAT).putString(path).putFileAttributes(attrs) ).ensureStatusPacketIsOK(); }