@NotNull String[] list(@NotNull String path) { FileInfo[] fileInfo = myKernel.listChildren(path); if (fileInfo == null || fileInfo.length == 0) { return ArrayUtil.EMPTY_STRING_ARRAY; } if (!StringUtil.endsWithChar(path, '/')) path += "/"; String[] names = new String[fileInfo.length]; Map<String, FileAttributes> map = getMap(); for (int i = 0, length = fileInfo.length; i < length; i++) { FileInfo info = fileInfo[i]; String name = info.getName(); map.put(path + name, info.toFileAttributes()); names[i] = name; } return names; }
private void doTest(File file) { String path = file.getPath(); long t1 = System.nanoTime(); File[] children1 = file.listFiles(); long t2 = System.nanoTime(); FileInfo[] children2 = myDriver.listChildren(path); long t3 = System.nanoTime(); myJavaTotal += (t2 - t1) / 1000; myIdeaTotal += (t3 - t2) / 1000; assertNotNull(path, children1); assertNotNull(path, children2); assertEquals(path, children1.length, children2.length); for (File child : children1) { if (child.isDirectory()) { doTest(child); } } }
@NotNull private static FileAttributes getAttributes(@NotNull final File file, final boolean checkList) { final FileAttributes attributes = FileSystemUtil.getAttributes(file); assertNotNull(attributes); if (SystemInfo.isWindows && checkList) { final String parent = file.getParent(); if (parent != null) { final FileInfo[] infos = IdeaWin32.getInstance().listChildren(parent); assertNotNull(infos); for (FileInfo info : infos) { if (file.getName().equals(info.getName())) { assertEquals(attributes, info.toFileAttributes()); return attributes; } } fail(file + " not listed"); } } return attributes; }
@NotNull String[] list(@NotNull String path) { FileInfo[] fileInfo = myKernel.listChildren(path); if (fileInfo == null || fileInfo.length == 0) { return ArrayUtil.EMPTY_STRING_ARRAY; } if (!path.endsWith("/")) path += "/"; List<String> names = new ArrayList<String>(fileInfo.length); Map<String, FileAttributes> map = getMap(); for (FileInfo info : fileInfo) { String name = info.getName(); map.put(path + name, info.toFileAttributes()); names.add(name); } return ArrayUtil.toStringArray(names); }
private void doTest(File file) { final String path = file.getPath(); assertNotNull(file.listFiles()); assertNotNull(myDriver.listChildren(path)); long t1 = System.nanoTime(); final File[] children1 = file.listFiles(); long t2 = System.nanoTime(); final FileInfo[] children2 = myDriver.listChildren(path); long t3 = System.nanoTime(); myJavaTotal += (t2 - t1) / 1000; myIdeaTotal += (t3 - t2) / 1000; assertNotNull(path, children1); assertNotNull(path, children2); assertEquals(children1.length, children2.length); for (File child : children1) { if (child.isDirectory()) { doTest(child); } } }
@Nonnull private static FileAttributes getAttributes(@Nonnull final File file, final boolean checkList) { final FileAttributes attributes = FileSystemUtil.getAttributes(file); assertNotNull(attributes); System.out.println(attributes + ": " + file); if (SystemInfo.isWindows && checkList) { final String parent = file.getParent(); if (parent != null) { final FileInfo[] infos = IdeaWin32.getInstance().listChildren(parent); assertNotNull(infos); for (FileInfo info : infos) { if (file.getName().equals(info.getName())) { assertEquals(attributes, info.toFileAttributes()); return attributes; } } fail(file + " not listed"); } } return attributes; }
@Nonnull String[] list(@Nonnull VirtualFile file) { String path = file.getPath(); FileInfo[] fileInfo = myKernel.listChildren(path); if (fileInfo == null || fileInfo.length == 0) { return ArrayUtil.EMPTY_STRING_ARRAY; } String[] names = new String[fileInfo.length]; TIntObjectHashMap<THashMap<String, FileAttributes>> map = getMap(); int parentId = ((VirtualFileWithId)file).getId(); THashMap<String, FileAttributes> nestedMap = map.get(parentId); if (nestedMap == null) { nestedMap = new THashMap<String, FileAttributes>(fileInfo.length, FileUtil.PATH_HASHING_STRATEGY); map.put(parentId, nestedMap); } for (int i = 0, length = fileInfo.length; i < length; i++) { FileInfo info = fileInfo[i]; String name = info.getName(); nestedMap.put(name, info.toFileAttributes()); names[i] = name; } return names; }
@Nullable FileAttributes getAttributes(@Nonnull VirtualFile file) { VirtualFile parent = file.getParent(); int parentId = parent instanceof VirtualFileWithId ? ((VirtualFileWithId)parent).getId() : -((VirtualFileWithId)file).getId(); TIntObjectHashMap<THashMap<String, FileAttributes>> map = getMap(); THashMap<String, FileAttributes> nestedMap = map.get(parentId); String name = file.getName(); FileAttributes attributes = nestedMap != null ? nestedMap.get(name) : null; if (attributes == null) { if (nestedMap != null && !(nestedMap instanceof IncompleteChildrenMap)) { return null; // our info from parent doesn't mention the child in this refresh session } FileInfo info = myKernel.getInfo(file.getPath()); if (info == null) { return null; } attributes = info.toFileAttributes(); if (nestedMap == null) { nestedMap = new IncompleteChildrenMap<>(FileUtil.PATH_HASHING_STRATEGY); map.put(parentId, nestedMap); } nestedMap.put(name, attributes); } return attributes; }
@Nullable FileAttributes getAttributes(@NotNull VirtualFile file) { String path = file.getPath(); Map<String, FileAttributes> map = getMap(); FileAttributes attributes = map.get(path); if (attributes == null) { FileInfo info = myKernel.getInfo(path); if (info == null) { return null; } attributes = info.toFileAttributes(); map.put(path, attributes); } return attributes; }
private static void assertDirectoriesEqual(@NotNull final File dir) { final String[] list1 = dir.list(); assertNotNull(list1); final FileInfo[] list2 = IdeaWin32.getInstance().listChildren(dir.getPath()); assertNotNull(list2); if (list1.length + 2 != list2.length) { assertEquals(Arrays.toString(list1), Arrays.toString(list2)); } }
private static void assertDirectoriesEqual(@Nonnull final File dir) { final String[] list1 = dir.list(); assertNotNull(list1); final FileInfo[] list2 = IdeaWin32.getInstance().listChildren(dir.getPath()); assertNotNull(list2); if (list1.length + 2 != list2.length) { assertEquals(Arrays.toString(list1), Arrays.toString(list2)); } }
@Override protected FileAttributes getAttributes(@NotNull final String path) throws Exception { final FileInfo fileInfo = myInstance.getInfo(path); return fileInfo != null ? fileInfo.toFileAttributes() : null; }
@Override public FileAttributes getAttributes(@NotNull final String path) throws Exception { final FileInfo fileInfo = myInstance.getInfo(path); return fileInfo != null ? fileInfo.toFileAttributes() : null; }
@Override protected FileAttributes getAttributes(@Nonnull final String path) throws Exception { final FileInfo fileInfo = myInstance.getInfo(path); return fileInfo != null ? fileInfo.toFileAttributes() : null; }