ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Peter Reilly" <peter.kitt.rei...@gmail.com>
Subject Re: svn commit: r549684 - /ant/core/trunk/src/main/org/apache/tools/ant/util/FileUtils.java
Date Fri, 22 Jun 2007 08:05:29 GMT
On 6/22/07, mbenson@apache.org <mbenson@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


Mime
View raw message