public String getDirectoryFilesName(String path, User currentUser, Directory currentDir) throws FileUnknownException, AccessDeniedException { if (path.equals(".")) return currentDir.getDirectoryFilesName(); else if (path.equals("..")) return currentDir.getFather().getDirectoryFilesName(); File target = absolutePath(path, currentUser, currentDir).getFileByName(getLastPathToken(path)); target.checkAccessRead(currentUser); return target.getDirectoryFilesName(); }
public Directory getLastDirectory(String path, Directory currentDir, User currentUser) throws FileUnknownException, PathIsTooBigException, AccessDeniedException { if (path.equals("/")) { getSlash().checkAccessEx(currentUser); return getSlash(); } if (path.equals(".")) return currentDir; else if (path.equals("..")) { currentDir.getFather().checkAccessEx(currentUser); return currentDir.getFather(); } Directory beforeLast = absolutePath(path, currentUser, currentDir); String[] tokens = path.split(PATH_DELIM); String name = tokens.length == 0 ? path : tokens[tokens.length - 1]; beforeLast.checkAccessEx(currentUser); beforeLast.changeDirectory(name, currentUser); return (Directory) beforeLast.getFileByName(name); }
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; }