[240408] A fix for case sensitive existence checking.
diff --git a/plugins/org.eclipse.wst.common.environment/.settings/org.eclipse.jdt.core.prefs b/plugins/org.eclipse.wst.common.environment/.settings/org.eclipse.jdt.core.prefs
index bd896db..f5f5f93 100644
--- a/plugins/org.eclipse.wst.common.environment/.settings/org.eclipse.jdt.core.prefs
+++ b/plugins/org.eclipse.wst.common.environment/.settings/org.eclipse.jdt.core.prefs
@@ -1,21 +1,21 @@
-#Mon Jan 30 10:37:36 EST 2006
+#Wed Jul 09 16:32:16 EDT 2008
 eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.4
+org.eclipse.jdt.core.compiler.compliance=1.5
 org.eclipse.jdt.core.compiler.debug.lineNumber=generate
 org.eclipse.jdt.core.compiler.debug.localVariable=generate
 org.eclipse.jdt.core.compiler.debug.sourceFile=generate
 org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
 org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
 org.eclipse.jdt.core.compiler.problem.deprecation=ignore
 org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
 org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
 org.eclipse.jdt.core.compiler.problem.discouragedReference=ignore
 org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
 org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
 org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
 org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
@@ -54,4 +54,4 @@
 org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
 org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
 org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
-org.eclipse.jdt.core.compiler.source=1.3
+org.eclipse.jdt.core.compiler.source=1.5
diff --git a/plugins/org.eclipse.wst.common.environment/META-INF/MANIFEST.MF b/plugins/org.eclipse.wst.common.environment/META-INF/MANIFEST.MF
index d7cf139..d527f18 100644
--- a/plugins/org.eclipse.wst.common.environment/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.wst.common.environment/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@
 Bundle-ManifestVersion: 2
 Bundle-Name: %pluginName
 Bundle-SymbolicName: org.eclipse.wst.common.environment
-Bundle-Version: 1.0.201.qualifier
+Bundle-Version: 1.0.202.qualifier
 Bundle-Activator: org.eclipse.wst.common.internal.environment.plugin.EnvironmentPlugin
 Bundle-Localization: plugin
 Export-Package: org.eclipse.wst.common.environment,
@@ -16,4 +16,4 @@
  org.eclipse.osgi.util;bundle-version="[3.1.300,4.0.0)"
 Bundle-Vendor: %providerName
 Eclipse-LazyStart: true 
-Bundle-RequiredExecutionEnvironment: J2SE-1.4
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
diff --git a/plugins/org.eclipse.wst.common.environment/src/org/eclipse/wst/common/internal/environment/eclipse/FileResourceUtils.java b/plugins/org.eclipse.wst.common.environment/src/org/eclipse/wst/common/internal/environment/eclipse/FileResourceUtils.java
index 240f43f..8d6a2cd 100644
--- a/plugins/org.eclipse.wst.common.environment/src/org/eclipse/wst/common/internal/environment/eclipse/FileResourceUtils.java
+++ b/plugins/org.eclipse.wst.common.environment/src/org/eclipse/wst/common/internal/environment/eclipse/FileResourceUtils.java
@@ -7,6 +7,9 @@
  *
  * Contributors:
  *     IBM Corporation - initial API and implementation
+ * yyyymmdd bug      Email and other contact information
+ * -------- -------- -----------------------------------------------------------
+ * 20080711   240408 rkklai@ca.ibm.com - Raymond Lai, support case-insensitive platform makeFile when a file with variant case exists
  *******************************************************************************/
 package org.eclipse.wst.common.internal.environment.eclipse;
 
@@ -15,11 +18,13 @@
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.util.Vector;
+
 import org.eclipse.core.resources.IContainer;
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IFolder;
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceStatus;
 import org.eclipse.core.resources.IWorkspace;
 import org.eclipse.core.resources.IWorkspaceRoot;
 import org.eclipse.core.resources.ResourcesPlugin;
@@ -31,8 +36,8 @@
 import org.eclipse.core.runtime.Status;
 import org.eclipse.osgi.util.NLS;
 import org.eclipse.wst.common.environment.Choice;
-import org.eclipse.wst.common.environment.StatusException;
 import org.eclipse.wst.common.environment.IStatusHandler;
+import org.eclipse.wst.common.environment.StatusException;
 
 
 
@@ -490,61 +495,80 @@
   // The container must already exist.
   //
  private static IFile makeFile (
-    IContainer       parent,
-    String           fileName,
-    InputStream      inputStream,
-    IStatusHandler    statusHandler )
- 
-    throws CoreException
-  {
-    IResource child  = parent.findMember(fileName);
-    
-    if( child != null )
-    {
-      if( child.getType() == IResource.FILE )
-      {        
-        //We have permission to overwrite so check if file is read-only
-        if( child.getResourceAttributes().isReadOnly() )
-        {
-          IFile[] files = new IFile[1];
-          files[0] = (IFile)child;
-          
-          IStatus status = getWorkspace().validateEdit(files,null);
-          
-          try
-          {
-            statusHandler.report( status );
-          }
-          catch( StatusException exc )
-          {
-            return null;
-          }
-        }
+		 IContainer       parent,
+		 String           fileName,
+		 InputStream      inputStream,
+		 IStatusHandler    statusHandler )
 
-        //Change the contents of the existing file.
-        IFile file = parent.getFile( new Path(fileName) );
-        file.setContents( inputStream, true, true, null );
-        
-        return file;
-      
-      }
-      else
-      {
-        throw new CoreException( 
-          new Status( IStatus.ERROR,
-                      "ResourceUtils",
-                      0, 
-				      NLS.bind( Messages.MSG_ERROR_RESOURCE_NOT_FILE, parent.getFullPath().append(fileName)),
-					  null ) );
-      }
-    }
-    else
-    {
-      //Create a new file.
-      IFile file = parent.getFile( new Path(fileName) );
-      file.create( inputStream, true, null);
-      
-      return file;
-    }
-  }
+ throws CoreException
+ {
+	 IFile file = parent.getFile( new Path(fileName) );
+
+	 // create the file if it doesn't exist
+	 if (!file.exists()) {
+		 try {
+			 file.create( inputStream, true, null);    
+			 return file;
+		 } catch (CoreException coreException) {
+			 // this error only happens in a case-insensitive file system; so ignore the cases.
+			 if (coreException.getStatus().getCode() == IResourceStatus.CASE_VARIANT_EXISTS) {
+				 boolean foundIgnoringCase = false;
+
+				 for (IResource resource : parent.members()) {
+					 if (resource.getName().equalsIgnoreCase(fileName)) {
+						 // found the file
+						 foundIgnoringCase = true;
+						 fileName = resource.getName();
+						 file = parent.getFile( new Path(fileName));
+						 break;
+					 }
+				 }
+
+				 // can't find the file causing the CASE_VARIANT_EXISTS exception; throw the exception
+				 if (!foundIgnoringCase)
+					 throw coreException;
+			 } else {
+				 // throw other exceptions
+				 throw coreException;
+			 }
+		 }
+	 }
+
+	 // file exists; overwrite the existing file
+	 if( file.getType() == IResource.FILE )
+	 {        
+		 //We have permission to overwrite so check if file is read-only
+		 if( file.getResourceAttributes().isReadOnly() )
+		 {
+			 IFile[] files = new IFile[1];
+			 files[0] = file;
+
+			 IStatus status = getWorkspace().validateEdit(files,null);
+
+			 try
+			 {
+				 statusHandler.report( status );
+			 }
+			 catch( StatusException exc )
+			 {
+				 return null;
+			 }
+		 }
+
+		 //Change the contents of the existing file.
+		 file.setContents( inputStream, true, true, null );
+
+		 return file;
+
+	 }
+	 else
+	 {
+		 throw new CoreException( 
+				 new Status( IStatus.ERROR,
+						 "ResourceUtils",
+						 0, 
+						 NLS.bind( Messages.MSG_ERROR_RESOURCE_NOT_FILE, parent.getFullPath().append(fileName)),
+						 null ) );
+	 }
+ }
 }