/** * @param path parent path * @param tree tree with a subpath * @return true if the subpath is directly under the path */ public static boolean hasParentPath(Path path, SubPath tree) { return path.equals(PathUtil.parentPath(tree.getSubPath())); }
private boolean deleteRes(DirRes<T> dirRes) { boolean removed = false; if (!dirRes.dir) { Resource<T> res = dirRes.res; removed = index.remove(res.getPath()) != null; Path parentPath = PathUtil.parentPath(res.getPath()); if (!PathUtil.isRoot(parentPath) && null != index.get(parentPath)) { DirRes<T> parentRes = index.get(parentPath); parentRes.dirList.remove(res.getPath()); //remove parent dir if empty dirRes = parentRes; } else { return removed; } } while (null != dirRes && dirRes.dir && dirRes.dirList.size() < 1) { index.remove(dirRes.getPath()); Path parentPath = PathUtil.parentPath(dirRes.getPath()); if (parentPath != null && !PathUtil.isRoot(parentPath)) { DirRes<T> parentRes = index.get(parentPath); parentRes.dirList.remove(dirRes.getPath()); dirRes = parentRes; } else { dirRes = null; } } return removed; }