You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by mb...@apache.org on 2007/06/22 05:10:21 UTC
svn commit: r549684 -
/ant/core/trunk/src/main/org/apache/tools/ant/util/FileUtils.java
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;
+ }
+ }
/**
* 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: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org
Re: svn commit: r549684 - /ant/core/trunk/src/main/org/apache/tools/ant/util/FileUtils.java
Posted by Matt Benson <gu...@yahoo.com>.
--- Steve Loughran <st...@apache.org> wrote:
> Peter Reilly wrote:
> > On 6/22/07, mbenson@apache.org
> <mb...@apache.org> 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.
> >
>
>
> Windows goes case sensitive if you mount samba FS or
> use clearcase. so
> its a directory-by-directory feature
Good point. Guess I will revert; I just hate doing
all these massive mods I'm working on with test
failures, and I suppose we can call it a bug in the OS
X JVM that files "foo" and "FOO" are considered
non-equal on a non-cs fs. WinXP, in contrast, says
the files are equal. Having only had my MBP for a
short while, I wasn't even aware the fs was non-cs
until yesterday. I was kind of disappointed but from
what I see on the web I might end up sorry if I
convert to the cs fs from an app interoperability
perspective. The fact remains we need a workaround
for this bug on non-cs filesystems where the JVM can't
give us the accurate info that "foo" and "FOO" are
equal. Does anyone have any better ideas? :(
-Matt
>
> -steve
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> dev-unsubscribe@ant.apache.org
> For additional commands, e-mail:
> dev-help@ant.apache.org
>
>
____________________________________________________________________________________Ready for the edge of your seat?
Check out tonight's top picks on Yahoo! TV.
http://tv.yahoo.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org
Re: svn commit: r549684 - /ant/core/trunk/src/main/org/apache/tools/ant/util/FileUtils.java
Posted by Steve Loughran <st...@apache.org>.
Peter Reilly wrote:
> On 6/22/07, mbenson@apache.org <mb...@apache.org> 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.
>
Windows goes case sensitive if you mount samba FS or use clearcase. so
its a directory-by-directory feature
-steve
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org
Re: svn commit: r549684 - /ant/core/trunk/src/main/org/apache/tools/ant/util/FileUtils.java
Posted by Peter Reilly <pe...@gmail.com>.
On 6/22/07, mbenson@apache.org <mb...@apache.org> 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: dev-unsubscribe@ant.apache.org
> For additional commands, e-mail: dev-help@ant.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org