Package org.apache.sshd.common.file

Examples of org.apache.sshd.common.file.SshFile.doesExist()


        } else {
            SshFxpStatRequest sshFxpStatRequest = (SshFxpStatRequest) sftpRequest;
            path = sshFxpStatRequest.getPath();
        }
        SshFile p = resolveFile(path);
        if (!p.doesExist()) {
            return new SshFxpStatusReply(id, SSH_FX_NO_SUCH_FILE, p.getAbsolutePath());
        }
        int flags = SSH_FILEXFER_ATTR_PERMISSIONS | SSH_FILEXFER_ATTR_SIZE;
        return new SshFxpAttrsReply(id, new FileAttributes(p, flags));
    }
View Full Code Here


        if (accValue == 0) {
            String path = request.getPath();
            int flags = request.getFlags();
            // attrs
            SshFile file = resolveFile(path);
            if (file.doesExist()) {
                if (((flags & SSH_FXF_CREAT) != 0) && ((flags & SSH_FXF_EXCL) != 0)) {
                    return new SshFxpStatusReply(id, SSH_FX_FILE_ALREADY_EXISTS, path);
                }
            } else {
                if ((flags & SSH_FXF_CREAT) != 0) {
View Full Code Here

            int flags = request.getFlags();
            // attrs
            SshFile file = resolveFile(path);
            switch (flags & SSH_FXF_ACCESS_DISPOSITION) {
                case SSH_FXF_CREATE_NEW: {
                    if (file.doesExist()) {
                        return new SshFxpStatusReply(id, SSH_FX_FILE_ALREADY_EXISTS, path);
                    } else if (!file.isWritable()) {
                        return new SshFxpStatusReply(id, SSH_FX_PERMISSION_DENIED, "Can not create " + path);
                    }
                    file.create();
View Full Code Here

                    }
                    file.create();
                    break;
                }
                case SSH_FXF_CREATE_TRUNCATE: {
                    if (file.doesExist()) {
                        return new SshFxpStatusReply(id, SSH_FX_FILE_ALREADY_EXISTS, path);
                    } else if (!file.isWritable()) {
                        return new SshFxpStatusReply(id, SSH_FX_PERMISSION_DENIED, "Can not create " + path);
                    }
                    file.truncate();
View Full Code Here

                    }
                    file.truncate();
                    break;
                }
                case SSH_FXF_OPEN_EXISTING: {
                    if (!file.doesExist()) {
                        if (!file.getParentFile().doesExist()) {
                            return new SshFxpStatusReply(id, SSH_FX_NO_SUCH_PATH, path);
                        } else {
                            return new SshFxpStatusReply(id, SSH_FX_NO_SUCH_FILE, path);
                        }
View Full Code Here

                        }
                    }
                    break;
                }
                case SSH_FXF_OPEN_OR_CREATE: {
                    if (!file.doesExist()) {
                        file.create();
                    }
                    break;
                }
                case SSH_FXF_TRUNCATE_EXISTING: {
View Full Code Here

                int pflags = buffer.getInt();
                Map<SshFile.Attribute, Object> attrs = readAttrs(buffer);
                log.debug("Received SSH_FXP_OPEN (path={}, pflags={}, attrs={})", new Object[] { path, pflags, attrs });
                try {
                    SshFile file = resolveFile(path);
                    if (file.doesExist()) {
                        if (((pflags & SSH_FXF_CREAT) != 0) && ((pflags & SSH_FXF_EXCL) != 0)) {
                            sendStatus(id, SSH_FX_FAILURE, path);
                            return;
                        }
                    } else {
View Full Code Here

            case SSH_FXP_OPENDIR: {
                String path = buffer.getString();
                log.debug("Received SSH_FXP_OPENDIR (path={})", path);
                try {
                    SshFile p = resolveFile(path);
                    if (!p.doesExist()) {
                        sendStatus(id, SSH_FX_NO_SUCH_FILE, path);
                    } else if (!p.isDirectory()) {
                        sendStatus(id, SSH_FX_NO_SUCH_FILE, path);
                    } else if (!p.isReadable()) {
                        sendStatus(id, SSH_FX_PERMISSION_DENIED, path);
View Full Code Here

            case SSH_FXP_REMOVE: {
                String path = buffer.getString();
                log.debug("Received SSH_FXP_REMOVE (path={})", path);
                try {
                    SshFile p = resolveFile(path);
                    if (!p.doesExist()) {
                        sendStatus(id, SSH_FX_NO_SUCH_FILE, p.getAbsolutePath());
                    } else if (p.isDirectory()) {
                        sendStatus(id, SSH_FX_NO_SUCH_FILE, p.getAbsolutePath());
                    } else if (!p.delete()) {
                        sendStatus(id, SSH_FX_FAILURE, "Failed to delete file");
View Full Code Here

                log.debug("Received SSH_FXP_MKDIR (path={})", path);
                // attrs
                try {
                    SshFile p = resolveFile(path);
                    if (p.doesExist()) {
                        if (p.isDirectory()) {
                            sendStatus(id, SSH_FX_FAILURE, p.getAbsolutePath());
                        } else {
                            sendStatus(id, SSH_FX_NO_SUCH_FILE, p.getAbsolutePath());
                        }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.