@TestOnly private static void assertAccessInTests( @NotNull VirtualFileSystemEntry child, @NotNull NewVirtualFileSystem delegate) { final Application application = ApplicationManager.getApplication(); if (IS_UNDER_TEAMCITY && SHOULD_PERFORM_ACCESS_CHECK && application.isUnitTestMode() && application instanceof ApplicationImpl && ((ApplicationImpl) application).isComponentsCreated()) { if (delegate != LocalFileSystem.getInstance() && delegate != JarFileSystem.getInstance()) { return; } // root' children are loaded always if (child.getParent() == null || child.getParent().getParent() == null) return; Set<String> allowed = allowedRoots(); boolean isUnder = allowed == null; if (!isUnder) { String childPath = child.getPath(); if (delegate == JarFileSystem.getInstance()) { VirtualFile local = JarFileSystem.getInstance().getVirtualFileForJar(child); assert local != null : child; childPath = local.getPath(); } for (String root : allowed) { if (FileUtil.startsWith(childPath, root)) { isUnder = true; break; } if (root.startsWith(JarFileSystem.PROTOCOL_PREFIX)) { String rootLocalPath = FileUtil.toSystemIndependentName(PathUtil.toPresentableUrl(root)); isUnder = FileUtil.startsWith(childPath, rootLocalPath); if (isUnder) break; } } } assert isUnder || allowed.isEmpty() : "File accessed outside allowed roots: " + child + ";\nAllowed roots: " + new ArrayList<String>(allowed); } }
@Override public String fun(VirtualFileSystemEntry file) { //noinspection HardCodedStringLiteral return file + " (name: '" + file.getName() + "', " + file.getClass() + ", parent: " + file.getParent() + "; id: " + file.getId() + "; FS: " + file.getFileSystem() + "; delegate.attrs: " + file.getFileSystem().getAttributes(file) + "; caseSensitive: " + file.getFileSystem().isCaseSensitive() + "; canonical: " + file.getFileSystem().getCanonicallyCasedName(file) + ") "; }
private static boolean isAdoptedChild(@NotNull VirtualFileSystemEntry v) { return v.getParent() == NULL_VIRTUAL_FILE; }