On 6/22/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
Author: mbenson
Date: Thu Jun 21 20:10:20 2007
New Revision: 549684
URL: http://svn.apache.org/viewvc?view=rev&rev=549684
Log:
detect cs
Modified:
ant/core/trunk/src/main/org/apache/tools/ant/util/FileUtils.java
Modified: ant/core/trunk/src/main/org/apache/tools/ant/util/FileUtils.java
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/util/FileUtils.java?view=diff&rev=549684&r1=549683&r2=549684
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/util/FileUtils.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/util/FileUtils.java Thu Jun 21
20:10:20 2007
@@ -15,7 +15,6 @@
* limitations under the License.
*
*/
-
package org.apache.tools.ant.util;
import java.io.File;
@@ -62,10 +61,13 @@
private static Random rand = new Random(System.currentTimeMillis()
+ Runtime.getRuntime().freeMemory());
- private static boolean onNetWare = Os.isFamily("netware");
- private static boolean onDos = Os.isFamily("dos");
- private static boolean onWin9x = Os.isFamily("win9x");
- private static boolean onWindows = Os.isFamily("windows");
+ private static final boolean onNetWare = Os.isFamily("netware");
+ private static final boolean onDos = Os.isFamily("dos");
+ private static final boolean onWin9x = Os.isFamily("win9x");
+ private static final boolean onWindows = Os.isFamily("windows");
+ private static final boolean onMac = Os.isFamily("mac");
+
+ private static boolean caseSensitiveFileSystem;
static final int BUF_SIZE = 8192;
@@ -87,6 +89,23 @@
*/
public static final long NTFS_FILE_TIMESTAMP_GRANULARITY = 1;
+ static {
+ try {
+ File tmpdir = new File(System.getProperty("java.io.tmpdir"));
+ final String filename = "ant-casesensitivity.tst";
+ new File(tmpdir, filename).createNewFile();
+ new File(tmpdir, filename.toUpperCase()).createNewFile();
+ String[] files = tmpdir.list(new FilenameFilter() {
+ public boolean accept(File dir, String name) {
+ return filename.equalsIgnoreCase(name);
+ }
+ });
+ caseSensitiveFileSystem = files.length == 2;
+ } catch (IOException e) {
+ //default as well as possible:
+ caseSensitiveFileSystem = !onWin9x && !onWindows && !onDos &&
!onMac;
+ }
+ }
Do we really want to do this each time ANT starts up?
Also, on Unix, one may have a mixture of filesystems, some of
which are case insensitive and some (well nearly all) not.
These may be mounted or symbolically linked to the anywhere in
the directory tree.
/**
* A one item cache for fromUri.
@@ -1181,8 +1200,9 @@
* @since Ant 1.5.3
*/
public boolean fileNameEquals(File f1, File f2) {
- return normalize(f1.getAbsolutePath())
- .equals(normalize(f2.getAbsolutePath()));
+ String name1 = normalize(f1.getAbsolutePath()).getAbsolutePath();
+ String name2 = normalize(f2.getAbsolutePath()).getAbsolutePath();
+ return caseSensitiveFileSystem ? name1.equals(name2) :
name1.equalsIgnoreCase(name2);
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]