Beispiel #1
0
 /**
  * Helper method - returns the targeted item (IResource if internal or IFileHandle if external),
  * or null if unbound Internal items must be referred to using container relative paths.
  */
 public static Object getTarget(IContainer container, IPath path, boolean checkResourceExistence) {
   if (path == null) return null;
   // lookup - inside the container
   if (path.getDevice() == null) { // container relative paths should not
     // contain a device
     // (see http://dev.eclipse.org/bugs/show_bug.cgi?id=18684)
     // (case of a workspace rooted at d:\ )
     IResource resource = container.findMember(path);
     if (resource != null) {
       if (!checkResourceExistence || resource.exists()) return resource;
       return null;
     }
   }
   // if path is relative, it cannot be an external path
   // (see http://dev.eclipse.org/bugs/show_bug.cgi?id=22517)
   if (!path.isAbsolute()) return null;
   // lookup - outside the container
   IFileHandle externalFile = EnvironmentPathUtils.getFile(path);
   if (externalFile != null) {
     if (!checkResourceExistence) {
       return externalFile;
     } else if (existingExternalFiles.contains(externalFile)) {
       return externalFile;
     } else {
       if (ModelManager.ZIP_ACCESS_VERBOSE) {
         System.out.println(
             "("
                 + Thread.currentThread()
                 + ") [Model.getTarget(...)] Checking existence of "
                 + path.toString()); // $NON-NLS-1$ //$NON-NLS-2$
       }
       if (externalFile.exists()) {
         // cache external file
         existingExternalFiles.add(externalFile);
         return externalFile;
       }
     }
   }
   return null;
 }