Program: 128545
Project: 128545
Buggy source:
/** 
 * Export the passed resource to the destination .zip.
 * @param exportResource org.eclipse.core.resources.IResource
 * @param leadupDepth the number of resource levels to be included in the path including the resourse itself.
 */
public void exportResource(String rootName,String directory,String exportResource,int leadupDepth) throws InterruptedException {
  File file=new File(exportResource);
  if (file.isFile()) {
    String destinationName=file.getName();
    if (!"String_Node_Str".equals(directory)) {
      if (directory.endsWith(SEPARATOR)) {
        destinationName=directory + file.getName();
      }
 else {
        destinationName=directory + SEPARATOR + file.getName();
      }
    }
    if (createLeadupStructure) {
      if (rootName != null && !"String_Node_Str".equals(destinationName)) {
        if (file.getName().equals(Messages.getString("String_Node_Str"))) {
          destinationName=rootName.substring(0,rootName.indexOf("String_Node_Str")) + SEPARATOR + destinationName;
        }
 else {
          destinationName=rootName + SEPARATOR + destinationName;
        }
      }
    }
    monitor.subTask(destinationName);
    try {
      exporter.write(exportResource,destinationName);
    }
 catch (    IOException e) {
      addError(NLS.bind("String_Node_Str",exportResource,e.getMessage()),e);
    }
catch (    CoreException e) {
      addError(NLS.bind("String_Node_Str",exportResource,e.getMessage()),e);
    }
    monitor.worked(1);
    ModalContext.checkCanceled(monitor);
  }
 else   if (file.isDirectory()) {
    File[] children=null;
    try {
      children=file.listFiles(new FileFilter(){
        public boolean accept(        File pathname){
          boolean result=true;
          if (pathname != null && pathname.isFile()) {
            try {
              result=Pattern.compile(regEx).matcher(pathname.getName()).find();
            }
 catch (            PatternSyntaxException e) {
            }
          }
          return result;
        }
      }
);
    }
 catch (    Exception e) {
      addError(NLS.bind("String_Node_Str",exportResource),e);
    }
    for (int i=0; i < children.length; i++) {
      exportResource(rootName,directory + file.getName() + SEPARATOR,children[i].getPath(),leadupDepth + 1);
    }
  }
}

Fixed version (ground truth):
/** 
 * Export the passed resource to the destination .zip.
 * @param exportResource org.eclipse.core.resources.IResource
 * @param leadupDepth the number of resource levels to be included in the path including the resourse itself.
 */
public void exportResource(String rootName,String directory,String exportResource,int leadupDepth) throws InterruptedException {
  File file=new File(exportResource);
  if (file.isFile()) {
    String destinationName=file.getName();
    if (!"String_Node_Str".equals(directory)) {
      if (directory.endsWith(SEPARATOR)) {
        destinationName=directory + file.getName();
      }
 else {
        destinationName=directory + SEPARATOR + file.getName();
      }
    }
    if (createLeadupStructure) {
      if (rootName != null && !"String_Node_Str".equals(destinationName)) {
        if (file.getName().equals(Messages.getString("String_Node_Str"))) {
          destinationName=rootName.substring(0,rootName.indexOf("String_Node_Str")) + SEPARATOR + destinationName;
        }
 else         if (!"String_Node_Str".equals(rootName)) {
          destinationName=rootName + SEPARATOR + destinationName;
        }
      }
    }
    destinationName=destinationName.replace("String_Node_Str",SEPARATOR);
    monitor.subTask(destinationName);
    try {
      exporter.write(exportResource,destinationName);
    }
 catch (    IOException e) {
      addError(NLS.bind("String_Node_Str",exportResource,e.getMessage()),e);
    }
catch (    CoreException e) {
      addError(NLS.bind("String_Node_Str",exportResource,e.getMessage()),e);
    }
    monitor.worked(1);
    ModalContext.checkCanceled(monitor);
  }
 else   if (file.isDirectory()) {
    File[] children=null;
    try {
      children=file.listFiles(new FileFilter(){
        public boolean accept(        File pathname){
          boolean result=true;
          if (pathname != null && pathname.isFile()) {
            try {
              result=Pattern.compile(regEx).matcher(pathname.getName()).find();
            }
 catch (            PatternSyntaxException e) {
            }
          }
          return result;
        }
      }
);
    }
 catch (    Exception e) {
      addError(NLS.bind("String_Node_Str",exportResource),e);
    }
    for (int i=0; i < children.length; i++) {
      exportResource(rootName,directory + file.getName() + SEPARATOR,children[i].getPath(),leadupDepth + 1);
    }
  }
}