private int dirRank(VirtualFile f) { try { if(f.isDirectory()) return 0; else return 1; } catch (IOException ex) { return 0; } } }
sub.isDirectory() ? null : childHref, length, parent.treeNodeId); r.tree.put(a, r.tree.remove(parent)); sub.isDirectory() ? null : childHref, length, "n" + ++r.idSeq); r.tree.put(a, parent!=null ? parent.treeNodeId : null); if (sub.isDirectory()) { n += addArtifacts(sub, childPath + '/', childHref + '/', r, a, upTo-n); if (n>=upTo) break;
/** * 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); }
private static void collectFiles(VirtualFile d, Collection<String> names, String prefix) throws IOException { for (VirtualFile child : d.list()) { if (child.isFile()) { names.add(prefix + child.getName()); } else if (child.isDirectory()) { collectFiles(child, names, prefix + child.getName() + "/"); } } } }
Path p = new Path(Util.rawEncode(f.getName()), f.getName(), f.isDirectory(), f.length(), f.canRead(), f.lastModified()); if(!f.isDirectory()) { r.add(Collections.singletonList(p)); } else { if (sub.size() !=1 || !sub.get(0).isDirectory()) break; f = sub.get(0);
if(baseFile.isDirectory()) { if(zip) { rsp.setContentType("application/zip"); for (VirtualFile kid : baseFile.list()) { os.write(kid.getName().getBytes("UTF-8")); if (kid.isDirectory()) { os.write('/');
private int dirRank(VirtualFile f) { try { if(f.isDirectory()) return 0; else return 1; } catch (IOException ex) { return 0; } } }
/** * 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); }
/** * Load artifacts from a given build. * @param sourceBuild a build which may have associated artifacts * @param console a way to print messages * @return a {@linkplain VirtualFile#isDirectory directory} of artifacts, or null if missing */ protected @CheckForNull VirtualFile getArtifacts(Run<?, ?> sourceBuild, PrintStream console) throws IOException, InterruptedException { if (Util.isOverridden(BuildSelector.class, getClass(), "getSourceDirectory", Run.class, PrintStream.class)) { FilePath old = getSourceDirectory(sourceBuild, console); return old != null ? old.toVirtualFile() : null; } else { VirtualFile root = sourceBuild.getArtifactManager().root(); return root.isDirectory() ? root : null; } }
sub.isDirectory() ? null : childHref, length, parent.getTreeNodeId()); r.tree.put(a, r.tree.remove(parent)); sub.isDirectory() ? null : childHref, length, "n" + ++r.idSeq); r.tree.put(a, parent!=null ? parent.getTreeNodeId() : null); if (sub.isDirectory()) { n += addArtifacts(sub, childPath + '/', childHref + '/', r, a, upTo-n); if (n>=upTo) break;
Path p = new Path(Util.rawEncode(f.getName()), f.getName(), f.isDirectory(), f.length(), f.canRead()); if(!f.isDirectory()) { r.add(Collections.singletonList(p)); } else { if (sub.size() !=1 || !sub.get(0).isDirectory()) break; f = sub.get(0);
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(); }
private boolean matchesFile(VirtualFile file, VirtualFile root) throws IOException { if (file.isDirectory()) { for (VirtualFile child : file.list()) { if (matchesFile(child, root)) { return true; } } } else if (nameMatcher.matches(fullName(file, root))) { if (contentMatcher.matches(file.open())) { return true; } } return false; }
if(baseFile.isDirectory()) { if(zip) { rsp.setContentType("application/zip"); for (VirtualFile kid : baseFile.list()) { os.write(kid.getName().getBytes("UTF-8")); if (kid.isDirectory()) { os.write('/');