@Before public void setUp() throws Exception { fakeFtpServer.setServerControlPort(0); fakeFtpServer.addUserAccount(new UserAccount(username, password, "c:\\data")); FileSystem fileSystem = new WindowsFakeFileSystem(); fileSystem.add(new DirectoryEntry("c:\\data")); fakeFtpServer.setFileSystem(fileSystem); fakeFtpServer.start(); ftpPort = fakeFtpServer.getServerControlPort(); }
DirectoryEntry directoryEntry = new DirectoryEntry(this.baseDir); directoryEntry.setPermissions(new Permissions("rwxrwxrwx")); fileSystem.add(directoryEntry);
add(new DirectoryEntry(normalizedToPath));
/** * 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; }
/** * Add the specified file system entry (file or directory) to this file system * * @param entry - the FileSystemEntry to add */ public void add(FileSystemEntry entry) { String path = entry.getPath(); checkForInvalidFilename(path); if (getEntry(path) != null) { throw new FileSystemException(path, "filesystem.pathAlreadyExists"); } if (!parentDirectoryExists(path)) { String parent = getParent(path); if (createParentDirectoriesAutomatically) { add(new DirectoryEntry(parent)); } else { throw new FileSystemException(parent, "filesystem.parentDirectoryDoesNotExist"); } } // Set lastModified, if not already set if (entry.getLastModified() == null) { entry.setLastModified(new Date()); } entries.put(getFileSystemEntryKey(path), entry); entry.lockPath(); }
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)); }