Java Code Examples for com.intellij.openapi.util.io.win32.FileInfo

The following are top voted examples for showing how to use com.intellij.openapi.util.io.win32.FileInfo. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: intellij-ce-playground   File: Win32FsCache.java   View source code 6 votes vote down vote up
@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;
}
 
Example 2
Project: intellij-ce-playground   File: IdeaWin32PerformanceTest.java   View source code 6 votes vote down vote up
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);
    }
  }
}
 
Example 3
Project: intellij-ce-playground   File: FileAttributesReadingTest.java   View source code 6 votes vote down vote up
@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;
}
 
Example 4
Project: tools-idea   File: Win32FsCache.java   View source code 6 votes vote down vote up
@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);
}
 
Example 5
Project: tools-idea   File: IdeaWin32PerformanceTest.java   View source code 6 votes vote down vote up
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);
    }
  }
}
 
Example 6
Project: tools-idea   File: FileAttributesReadingTest.java   View source code 6 votes vote down vote up
@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;
}
 
Example 7
Project: consulo   File: IdeaWin32PerformanceTest.java   View source code 6 votes vote down vote up
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);
    }
  }
}
 
Example 8
Project: consulo   File: FileAttributesReadingTest.java   View source code 6 votes vote down vote up
@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;
}
 
Example 9
Project: consulo   File: Win32FsCache.java   View source code 6 votes vote down vote up
@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;
}
 
Example 10
Project: consulo   File: Win32FsCache.java   View source code 6 votes vote down vote up
@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;
}
 
Example 11
Project: intellij-ce-playground   File: Win32FsCache.java   View source code 5 votes vote down vote up
@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;
}
 
Example 12
Project: intellij-ce-playground   File: FileAttributesReadingTest.java   View source code 5 votes vote down vote up
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));
  }
}
 
Example 13
Project: tools-idea   File: Win32FsCache.java   View source code 5 votes vote down vote up
@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;
}
 
Example 14
Project: tools-idea   File: FileAttributesReadingTest.java   View source code 5 votes vote down vote up
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));
  }
}
 
Example 15
Project: consulo   File: FileAttributesReadingTest.java   View source code 5 votes vote down vote up
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));
  }
}
 
Example 16
Project: intellij-ce-playground   File: FileSystemUtil.java   View source code 4 votes vote down vote up
@Override
protected FileAttributes getAttributes(@NotNull final String path) throws Exception {
  final FileInfo fileInfo = myInstance.getInfo(path);
  return fileInfo != null ? fileInfo.toFileAttributes() : null;
}
 
Example 17
Project: tools-idea   File: FileSystemUtil.java   View source code 4 votes vote down vote up
@Override
public FileAttributes getAttributes(@NotNull final String path) throws Exception {
  final FileInfo fileInfo = myInstance.getInfo(path);
  return fileInfo != null ? fileInfo.toFileAttributes() : null;
}
 
Example 18
Project: consulo   File: FileSystemUtil.java   View source code 4 votes vote down vote up
@Override
protected FileAttributes getAttributes(@Nonnull final String path) throws Exception {
  final FileInfo fileInfo = myInstance.getInfo(path);
  return fileInfo != null ? fileInfo.toFileAttributes() : null;
}