Beispiel #1
0
  public void testFindFilesByLocation() throws Exception {
    fProject.create(new NullProgressMonitor());
    fProject.open(new NullProgressMonitor());
    createFolder(fProject, "folder1");
    createFolder(fProject, "folder2");
    IFile file = createFile(fProject, "abc.h");
    createFile(fProject, "folder1/abc.h");
    createFile(fProject, "folder2/abC.h");

    URI uri = file.getLocationURI();
    IPath path = file.getLocation();
    IFile[] files = ResourceLookup.findFilesForLocationURI(uri);
    assertEquals(1, files.length);
    files = ResourceLookup.findFilesForLocation(path);
    assertEquals(1, files.length);

    if (new File("a").equals(new File("A"))) {
      URI upperCase =
          new URI(uri.getScheme(), uri.getSchemeSpecificPart().toUpperCase(), uri.getFragment());
      IPath upperCasePath = new Path(path.toString().toUpperCase());
      files = ResourceLookup.findFilesForLocationURI(upperCase);
      assertEquals(1, files.length);
      files = ResourceLookup.findFilesForLocation(upperCasePath);
      assertEquals(1, files.length);
    }
  }
 /** Returns whether the given URI points within the workspace. */
 private static boolean isWorkspaceFile(URI uri) {
   for (IFile file : ResourceLookup.findFilesForLocationURI(uri)) {
     if (file.exists()) {
       return true;
     }
   }
   return false;
 }