protected String error(StatusCode sc) throws SFTPException { try { throw new SFTPException(sc, protocolVersion < 3 ? sc.toString() : readString()); } catch (BufferException be) { throw new SFTPException(be); } }
final int count = res.readUInt32AsInt(); for (int i = 0; i < count; i++) { final String name = res.readString(requester.sub.getRemoteCharset()); res.readString(); // long name - IGNORED - shdve never been in the protocol final FileAttributes attrs = res.readFileAttributes(); final PathComponents comps = requester.getPathHelper().getComponents(path, name);
protected String error(StatusCode sc) throws SFTPException { try { throw new SFTPException(sc, protocolVersion < 3 ? sc.toString() : readString()); } catch (BufferException be) { throw new SFTPException(be); } }
protected String error(StatusCode sc) throws SFTPException { try { throw new SFTPException(sc, protocolVersion < 3 ? sc.toString() : readString()); } catch (BufferException be) { throw new SFTPException(be); } }
protected static String readSingleName(Response res) throws IOException { res.ensurePacketTypeIs(PacketType.NAME); if (res.readUInt32AsInt() == 1) return res.readString(); else throw new SFTPException("Unexpected data in " + res.getType() + " packet"); }
public RemoteDirectory openDir(String path) throws IOException { final String handle = doRequest( newRequest(PacketType.OPENDIR).putString(path) ).ensurePacketTypeIs(PacketType.HANDLE).readString(); return new RemoteDirectory(this, path, handle); }
public List<RemoteResourceInfo> scan(RemoteResourceFilter filter) throws IOException { List<RemoteResourceInfo> rri = new LinkedList<RemoteResourceInfo>(); loop: for (; ; ) { final Response res = requester.request(newRequest(PacketType.READDIR)) .retrieve(requester.getTimeoutMs(), TimeUnit.MILLISECONDS); switch (res.getType()) { case NAME: final int count = res.readUInt32AsInt(); for (int i = 0; i < count; i++) { final String name = res.readString(); res.readString(); // long name - IGNORED - shdve never been in the protocol final FileAttributes attrs = res.readFileAttributes(); final PathComponents comps = requester.getPathHelper().getComponents(path, name); final RemoteResourceInfo inf = new RemoteResourceInfo(comps, attrs); if (!(name.equals(".") || name.equals("..")) && (filter == null || filter.accept(inf))) rri.add(inf); } break; case STATUS: res.ensureStatusIs(StatusCode.EOF); break loop; default: throw new SFTPException("Unexpected packet: " + res.getType()); } } return rri; }
final int count = res.readUInt32AsInt(); for (int i = 0; i < count; i++) { final String name = res.readString(requester.sub.getRemoteCharset()); res.readString(); // long name - IGNORED - shdve never been in the protocol final FileAttributes attrs = res.readFileAttributes(); final PathComponents comps = requester.getPathHelper().getComponents(path, name);
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); }