@Override @NotNull public VirtualFile[] getRoots() { myRootsLock.readLock().lock(); try { Collection<VirtualFileSystemEntry> roots = myRoots.values(); return VfsUtilCore.toVirtualFileArray(roots); } finally { myRootsLock.readLock().unlock(); } }
@Nullable public static ContentEntry findContentEntryForRoot( @NotNull ModifiableRootModel model, @NotNull VirtualFile root) { ContentEntry contentEntry = null; for (ContentEntry candidate : model.getContentEntries()) { VirtualFile contentRoot = candidate.getFile(); if (contentRoot != null && VfsUtilCore.isAncestor(contentRoot, root, false)) { contentEntry = candidate; } } return contentEntry; }
@Override @NotNull public VirtualFile[] getLocalRoots() { List<VirtualFile> roots = ContainerUtil.newSmartList(); myRootsLock.readLock().lock(); try { for (NewVirtualFile root : myRoots.values()) { if (root.isInLocalFileSystem() && !(root.getFileSystem() instanceof TempFileSystem)) { roots.add(root); } } } finally { myRootsLock.readLock().unlock(); } return VfsUtilCore.toVirtualFileArray(roots); }
@Override @NotNull public VirtualFile[] getRoots(@NotNull final NewVirtualFileSystem fs) { final List<VirtualFile> roots = new ArrayList<VirtualFile>(); myRootsLock.readLock().lock(); try { for (NewVirtualFile root : myRoots.values()) { if (root.getFileSystem() == fs) { roots.add(root); } } } finally { myRootsLock.readLock().unlock(); } return VfsUtilCore.toVirtualFileArray(roots); }
private static void makeAndAddLibraryJar( final VirtualFile virtualFile, final File zipFile, final String pluginName, final ZipOutputStream zos, final Set<String> usedJarNames, final ProgressIndicator progressIndicator, final String preferredName) throws IOException { File libraryJar = FileUtil.createTempFile(TEMP_PREFIX, JAR_EXTENSION); libraryJar.deleteOnExit(); ZipOutputStream jar = null; try { jar = new JarOutputStream(new BufferedOutputStream(new FileOutputStream(libraryJar))); ZipUtil.addFileOrDirRecursively( jar, libraryJar, VfsUtilCore.virtualToIoFile(virtualFile), "", createFilter(progressIndicator, FileTypeManager.getInstance()), null); } finally { if (jar != null) jar.close(); } final String jarName = getLibraryJarName( virtualFile.getName() + JAR_EXTENSION, usedJarNames, preferredName == null ? null : preferredName + JAR_EXTENSION); ZipUtil.addFileOrDirRecursively( zos, zipFile, libraryJar, getZipPath(pluginName, jarName), createFilter(progressIndicator, null), null); }