/** * Builds the path list and href recursively top-down. */ private static void buildPathList(VirtualFile baseDir, VirtualFile filePath, List<Path> pathList, StringBuilder href) throws IOException { VirtualFile parent = filePath.getParent(); if (!baseDir.equals(parent)) { buildPathList(baseDir, parent, pathList, href); } href.append(Util.rawEncode(filePath.getName())); if (filePath.isDirectory()) { href.append("/"); } Path path = new Path(href.toString(), filePath.getName(), filePath.isDirectory(), filePath.length(), filePath.canRead(), filePath.lastModified()); pathList.add(path); }
/** * Builds the path list and href recursively top-down. */ private static void buildPathList(VirtualFile baseDir, VirtualFile filePath, List<Path> pathList, StringBuilder href) throws IOException { VirtualFile parent = filePath.getParent(); if (!baseDir.equals(parent)) { buildPathList(baseDir, parent, pathList, href); } href.append(Util.rawEncode(filePath.getName())); if (filePath.isDirectory()) { href.append("/"); } Path path = new Path(href.toString(), filePath.getName(), filePath.isDirectory(), filePath.length(), filePath.canRead()); pathList.add(path); }
private String fullName(VirtualFile file, VirtualFile root) throws IOException { StringBuilder name = new StringBuilder(file.getName()); VirtualFile parent = file.getParent(); while (parent != null && parent.isDirectory() && !parent.equals(root)) { if(!StringUtils.isEmpty(parent.getName())) { name.insert(0, parent.getName() + "/"); } parent = parent.getParent(); } return name.toString(); }