|
|
@@ -15,7 +15,6 @@ |
|
|
|
* limitations under the License. |
|
|
|
* |
|
|
|
*/ |
|
|
|
|
|
|
|
package org.apache.tools.ant.util; |
|
|
|
|
|
|
|
import java.io.File; |
|
|
@@ -62,10 +61,13 @@ public class FileUtils { |
|
|
|
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 class FileUtils { |
|
|
|
*/ |
|
|
|
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; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* A one item cache for fromUri. |
|
|
@@ -1181,8 +1200,9 @@ public class FileUtils { |
|
|
|
* @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); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|