directoryEntry.setPermissions(new Permissions("rwxrwxrwx")); fileSystem.add(directoryEntry); fakeFtpServer.setFileSystem(fileSystem);
/** * Return a new FileSystemEntry that is a clone of this object, except having the specified path * * @param path - the new path value for the cloned file system entry * @return a new FileSystemEntry that has all the same values as this object except for its path */ public FileSystemEntry cloneWithNewPath(String path) { DirectoryEntry clone = new DirectoryEntry(path); clone.setLastModified(getLastModified()); clone.setOwner(getOwner()); clone.setGroup(getGroup()); clone.setPermissions(getPermissions()); return clone; }
protected void handle(Command command, Session session) { verifyLoggedIn(session); String path = getRealPath(session, command.getRequiredParameter(0)); String parent = getFileSystem().getParent(path); this.replyCodeForFileSystemException = ReplyCodes.READ_FILE_ERROR; verifyFileSystemCondition(getFileSystem().exists(parent), parent, "filesystem.doesNotExist"); verifyFileSystemCondition(!getFileSystem().exists(path), path, "filesystem.alreadyExists"); // User must have write permission to the parent directory verifyWritePermission(session, parent); // User must have execute permission to the parent directory verifyExecutePermission(session, parent); DirectoryEntry dirEntry = new DirectoryEntry(path); getFileSystem().add(dirEntry); dirEntry.setPermissions(getUserAccount(session).getDefaultPermissionsForNewDirectory()); sendReply(session, ReplyCodes.MKD_OK, "mkd", list(path)); }