Package org.apache.sshd.server

Examples of org.apache.sshd.server.SshFile.doesExist()


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


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

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

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

                                    file.create();
                                }
                                break;
                            }
                            case SSH_FXF_TRUNCATE_EXISTING: {
                                if (!file.doesExist()) {
                                    if (!file.getParentFile().doesExist()) {
                                        sendStatus(id, SSH_FX_NO_SUCH_PATH, path);
                                    } else {
                                        sendStatus(id, SSH_FX_NO_SUCH_FILE, path);
                                    }
View Full Code Here

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

            }
            case SSH_FXP_REMOVE: {
                String path = buffer.getString();
                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_FILE_IS_A_DIRECTORY, p.getAbsolutePath());
                    } else if (!p.delete()) {
                        sendStatus(id, SSH_FX_FAILURE, "Failed to delete file");
View Full Code Here

            case SSH_FXP_MKDIR: {
                String path = buffer.getString();
                // attrs
                try {
                    SshFile p = resolveFile(path);
                    if (p.doesExist()) {
                        if (p.isDirectory()) {
                            sendStatus(id, SSH_FX_FILE_ALREADY_EXISTS, p.getAbsolutePath());
                        } else {
                            sendStatus(id, SSH_FX_NOT_A_DIRECTORY, p.getAbsolutePath());
                        }
View Full Code Here

                String path = buffer.getString();
                // attrs
                try {
                    SshFile p = resolveFile(path);
                    if (p.isDirectory()) {
                        if (p.doesExist()) {
                            if (p.listSshFiles().size() == 0) {
                                if (p.delete()) {
                                    sendStatus(id, SSH_FX_OK, "");
                                } else {
                                    sendStatus(id, SSH_FX_FAILURE, "Unable to delete directory " + path);
View Full Code Here

                try {
                    SshFile o = resolveFile(oldPath);
                    SshFile n = resolveFile(newPath);
                    if (!o.doesExist()) {
                        sendStatus(id, SSH_FX_NO_SUCH_FILE, o.getAbsolutePath());
                    } else if (n.doesExist()) {
                        sendStatus(id, SSH_FX_FILE_ALREADY_EXISTS, n.getAbsolutePath());
                    } else if (!o.move(n)) {
                        sendStatus(id, SSH_FX_FAILURE, "Failed to rename file");
                    } else {
                        sendStatus(id, SSH_FX_OK, "");
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.