You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by gn...@apache.org on 2014/04/07 11:26:20 UTC

[2/2] git commit: [SSHD-306] Add checkDir / checkData extension points in DefaultSftpClient

[SSHD-306] Add checkDir / checkData extension points in DefaultSftpClient

Project: http://git-wip-us.apache.org/repos/asf/mina-sshd/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina-sshd/commit/f8767d48
Tree: http://git-wip-us.apache.org/repos/asf/mina-sshd/tree/f8767d48
Diff: http://git-wip-us.apache.org/repos/asf/mina-sshd/diff/f8767d48

Branch: refs/heads/master
Commit: f8767d486da31f30ee97b7054afd2b193db1edc0
Parents: 78be94f
Author: Guillaume Nodet <gn...@apache.org>
Authored: Mon Apr 7 11:25:44 2014 +0200
Committer: Guillaume Nodet <gn...@apache.org>
Committed: Mon Apr 7 11:26:08 2014 +0200

----------------------------------------------------------------------
 .../org/apache/sshd/client/sftp/DefaultSftpClient.java   | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f8767d48/sshd-core/src/main/java/org/apache/sshd/client/sftp/DefaultSftpClient.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/sftp/DefaultSftpClient.java b/sshd-core/src/main/java/org/apache/sshd/client/sftp/DefaultSftpClient.java
index 5a8f8c7..abd8106 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/sftp/DefaultSftpClient.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/sftp/DefaultSftpClient.java
@@ -449,7 +449,11 @@ public class DefaultSftpClient implements SftpClient {
         buffer.putString(handle.id);
         buffer.putLong(fileOffset);
         buffer.putInt(len);
-        buffer = receive(send(SSH_FXP_READ, buffer));
+        return checkData(receive(send(SSH_FXP_READ, buffer)), dstoff, dst);
+    }
+
+    protected int checkData(Buffer buffer, int dstoff, byte[] dst) throws SshException {
+        int len;
         int length = buffer.getInt();
         int type = buffer.getByte();
         int id = buffer.getInt();
@@ -500,7 +504,10 @@ public class DefaultSftpClient implements SftpClient {
     public DirEntry[] readDir(Handle handle) throws IOException {
         Buffer buffer = new Buffer();
         buffer.putString(handle.id);
-        buffer = receive(send(SSH_FXP_READDIR, buffer));
+        return checkDir(receive(send(SSH_FXP_READDIR, buffer)));
+    }
+
+    protected DirEntry[] checkDir(Buffer buffer) throws IOException {
         int length = buffer.getInt();
         int type = buffer.getByte();
         int id = buffer.getInt();