void createPlainFile(String path, Directory currentDirectory, User currentUser) throws InvalidFileNameException, InvalidMaskException, FileAlreadyExistsException { Directory directory = absolutePath(path, currentUser, currentDirectory); String filename = getLastPathToken(path); directory.checkAccessWrite(currentUser); for (File f : directory.getFilesSet()) { if (f.getFilename().equals(filename)) throw new FileAlreadyExistsException(filename); } directory.addFile( new PlainFile( this.generateUniqueId(), filename, currentUser.getUmask(), currentUser, directory)); }
private ArrayList<File> getRecursiveRemovalContent(Directory currentDir) { ArrayList<File> toBeRemoved = new ArrayList<>(); for (File f : currentDir.getFilesSet()) { if (!f.equals(currentDir.getFather()) && !f.equals(currentDir)) { try { f.isCdAble(); toBeRemoved.addAll(getRecursiveRemovalContent((Directory) f)); } catch (IsNotDirectoryException e) { // in case of delete plainfiles } finally { toBeRemoved.add(f); } } } return toBeRemoved; }