/**
   * Called by the console line parsers to find a file with a given name.
   *
   * @param fileName
   * @return IFile or null
   */
  public IFile findFile(String fileName) {
    IFile file = findFilePath(fileName);
    if (file == null) {
      // Try the project's map.
      file = findFileName(fileName);
      if (file != null) {
        // If there is a conflict then try all files in the project.
        if (isConflictingName(fileName)) {
          file = null;

          // Create a problem marker
          final String error =
              MakeMessages.getString(
                  "ConsoleParser.Ambiguous_Filepath_Error_Message"); //$NON-NLS-1$
          TraceUtil.outputError(error, fileName);
          generateMarker(
              getProject(), -1, error + fileName, IMarkerGenerator.SEVERITY_WARNING, null);
        }
      }
    }
    return file;
  }
  public List translateRelativePaths(IFile file, String fileName, List includes) {
    List translatedIncludes = new ArrayList(includes.size());
    for (Iterator i = includes.iterator(); i.hasNext(); ) {
      String include = (String) i.next();
      IPath includePath = new Path(include);
      if (!includePath.isAbsolute() && !includePath.isUNC()) { // do not translate UNC paths
        // First try the current working directory
        IPath cwd = getWorkingDirectory();
        if (!cwd.isAbsolute()) {
          cwd = getBaseDirectory().append(cwd);
        }

        IPath filePath = new Path(fileName);
        if (!filePath.isAbsolute()) {
          // check if the cwd is the right one
          // appending fileName to cwd should yield file path
          filePath = cwd.append(fileName);
        }
        if (!filePath.toString().equalsIgnoreCase(file.getLocation().toString())) {
          // must be the cwd is wrong
          // check if file name starts with ".."
          if (fileName.startsWith("..")) { // $NON-NLS-1$
            // probably multiple choices for cwd, hopeless
            final String error =
                MakeMessages.getString(
                    "ConsoleParser.Working_Directory_Error_Message"); //$NON-NLS-1$
            TraceUtil.outputError(error, fileName);
            generateMarker(file, -1, error, IMarkerGenerator.SEVERITY_WARNING, fileName);
            break;
          } else {
            // remove common segments at the end
            IPath tPath = new Path(fileName);
            if (fileName.startsWith(".")) { // $NON-NLS-1$
              tPath = tPath.removeFirstSegments(1);
            }
            // get the file path from the file
            filePath = file.getLocation();
            IPath lastFileSegment =
                filePath.removeFirstSegments(filePath.segmentCount() - tPath.segmentCount());
            if (lastFileSegment.matchingFirstSegments(tPath) == tPath.segmentCount()) {
              cwd = filePath.removeLastSegments(tPath.segmentCount());
            }
          }
        }

        IPath candidatePath = cwd.append(includePath);
        File dir = candidatePath.toFile();
        include = candidatePath.toString();
        if (!dir.exists()) {
          final String error =
              MakeMessages.getString(
                  "ConsoleParser.Nonexistent_Include_Path_Error_Message"); //$NON-NLS-1$
          TraceUtil.outputError(error, include);
          //					generateMarker(file, -1, error+include, IMarkerGenerator.SEVERITY_WARNING,
          // fileName);
        }
      }
      // TODO VMIR for now add unresolved paths as well
      translatedIncludes.add(include);
    }
    return translatedIncludes;
  }