Package org.apache.sshd.common.util

Examples of org.apache.sshd.common.util.Buffer


        buffer.putInt(0);
        return checkHandle(receive(send(SSH_FXP_OPEN, buffer)));
    }

    public void close(Handle handle) throws IOException {
        Buffer buffer = new Buffer();
        buffer.putString(handle.id);
        checkStatus(receive(send(SSH_FXP_CLOSE, buffer)));
    }
View Full Code Here


        buffer.putString(handle.id);
        checkStatus(receive(send(SSH_FXP_CLOSE, buffer)));
    }

    public void remove(String path) throws IOException {
        Buffer buffer = new Buffer();
        buffer.putString(path);
        checkStatus(receive(send(SSH_FXP_REMOVE, buffer)));
    }
View Full Code Here

        buffer.putString(path);
        checkStatus(receive(send(SSH_FXP_REMOVE, buffer)));
    }

    public void rename(String oldPath, String newPath) throws IOException {
        Buffer buffer = new Buffer();
        buffer.putString(oldPath);
        buffer.putString(newPath);
        checkStatus(receive(send(SSH_FXP_RENAME, buffer)));
    }
View Full Code Here

        buffer.putString(newPath);
        checkStatus(receive(send(SSH_FXP_RENAME, buffer)));
    }

    public int read(Handle handle, long fileOffset, byte[] dst, int dstoff, int len) throws IOException {
        Buffer buffer = new Buffer();
        buffer.putString(handle.id);
        buffer.putLong(fileOffset);
        buffer.putInt(len);
        buffer = receive(send(SSH_FXP_READ, buffer));
        int length = buffer.getInt();
        int type = buffer.getByte();
        int id = buffer.getInt();
        if (type == SSH_FXP_STATUS) {
            int substatus = buffer.getInt();
            String msg = buffer.getString();
            String lang = buffer.getString();
            if (substatus == SSH_FX_EOF) {
                return -1;
            }
            throw new SshException("SFTP error (" + substatus + "): " + msg);
        } else if (type == SSH_FXP_DATA) {
            len = buffer.getInt();
            buffer.getRawBytes(dst, dstoff, len);
            return len;
        } else {
            throw new SshException("Unexpected SFTP packet received: " + type);
        }
    }
View Full Code Here

            throw new SshException("Unexpected SFTP packet received: " + type);
        }
    }

    public void write(Handle handle, long fileOffset, byte[] src, int srcoff, int len) throws IOException {
        Buffer buffer = new Buffer();
        buffer.putString(handle.id);
        buffer.putLong(fileOffset);
        buffer.putBytes(src, srcoff, len);
        checkStatus(receive(send(SSH_FXP_WRITE, buffer)));
    }
View Full Code Here

        if (closeFuture.isClosed()) {
            throw new SshException("Session has been closed");
        }
        openFuture = new DefaultOpenFuture(lock);
        log.info("Send SSH_MSG_CHANNEL_OPEN on channel {}", id);
        Buffer buffer = session.createBuffer(SshConstants.Message.SSH_MSG_CHANNEL_OPEN, 0);
        buffer.putString(type);
        buffer.putInt(id);
        buffer.putInt(localWindow.getSize());
        buffer.putInt(localWindow.getPacketSize());
        writePacket(buffer);
        return openFuture;
    }
View Full Code Here

        buffer.putBytes(src, srcoff, len);
        checkStatus(receive(send(SSH_FXP_WRITE, buffer)));
    }

    public void mkdir(String path) throws IOException {
        Buffer buffer = new Buffer();
        buffer.putString(path);
        checkStatus(receive(send(SSH_FXP_MKDIR, buffer)));
    }
View Full Code Here

        buffer.putString(path);
        checkStatus(receive(send(SSH_FXP_MKDIR, buffer)));
    }

    public void rmdir(String path) throws IOException {
        Buffer buffer = new Buffer();
        buffer.putString(path);
        checkStatus(receive(send(SSH_FXP_RMDIR, buffer)));
    }
View Full Code Here

        buffer.putString(path);
        checkStatus(receive(send(SSH_FXP_RMDIR, buffer)));
    }

    public Handle openDir(String path) throws IOException {
        Buffer buffer = new Buffer();
        buffer.putString(path);
        return checkHandle(receive(send(SSH_FXP_OPENDIR, buffer)));
    }
View Full Code Here

        buffer.putString(path);
        return checkHandle(receive(send(SSH_FXP_OPENDIR, buffer)));
    }

    public DirEntry[] readDir(Handle handle) throws IOException {
        Buffer buffer = new Buffer();
        buffer.putString(handle.id);
        buffer = receive(send(SSH_FXP_READDIR, buffer));
        int length = buffer.getInt();
        int type = buffer.getByte();
        int id = buffer.getInt();
        if (type == SSH_FXP_STATUS) {
            int substatus = buffer.getInt();
            String msg = buffer.getString();
            String lang = buffer.getString();
            if (substatus == SSH_FX_EOF) {
                return null;
            }
            throw new SshException("SFTP error (" + substatus + "): " + msg);
        } else if (type == SSH_FXP_NAME) {
            int len = buffer.getInt();
            DirEntry[] entries = new DirEntry[len];
            for (int i = 0; i < len; i++) {
                String name = buffer.getString();
                String longName = buffer.getString();
                Attributes attrs = readAttributes(buffer);
                entries[i] = new DirEntry(name, longName, attrs);
            }
            return entries;
        } else {
View Full Code Here

TOP

Related Classes of org.apache.sshd.common.util.Buffer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.