jkf         2005/01/04 12:20:52

  Modified:    src/main/org/apache/tools/ant/util FileUtils.java
               src/main/org/apache/tools/ant/types/selectors
                        MappingSelector.java DateSelector.java
               src/main/org/apache/tools/ant/taskdefs Copy.java
                        DependSet.java
  Log:
  Made more consequent use of the method available in FileUtils to get the 
granularity.
  
  Revision  Changes    Path
  1.80      +16 -4     ant/src/main/org/apache/tools/ant/util/FileUtils.java
  
  Index: FileUtils.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/util/FileUtils.java,v
  retrieving revision 1.79
  retrieving revision 1.80
  diff -u -r1.79 -r1.80
  --- FileUtils.java    15 Dec 2004 12:10:43 -0000      1.79
  +++ FileUtils.java    4 Jan 2005 20:20:49 -0000       1.80
  @@ -1,5 +1,5 @@
   /*
  - * Copyright  2001-2004 The Apache Software Foundation
  + * Copyright  2001-2005 The Apache Software Foundation
    *
    *  Licensed under the Apache License, Version 2.0 (the "License");
    *  you may not use this file except in compliance with the License.
  @@ -58,11 +58,14 @@
    */
   
   public class FileUtils {
  +    
  +    private static final FileUtils PRIMARY_INSTANCE = new FileUtils();
  +    
       //get some non-crypto-grade randomness from various places.
       private static Random rand = new Random(System.currentTimeMillis()
               + Runtime.getRuntime().freeMemory());
   
  -    private boolean onNetWare = Os.isFamily("netware");
  +    private static boolean onNetWare = Os.isFamily("netware");
   
       // for toURI
       private static boolean[] isSpecial = new boolean[256];
  @@ -106,12 +109,22 @@
        * Factory method.
        *
        * @return a new instance of FileUtils.
  +     * @deprecated Use getFileUtils instead, FileUtils do not have state.
        */
       public static FileUtils newFileUtils() {
           return new FileUtils();
       }
   
       /**
  +     * Method to retrieve The FileUtils, which is shared by all users of this
  +     * method.
  +     * @return an instance of FileUtils.
  +     */
  +    public static FileUtils getFileUtils() {
  +        return PRIMARY_INSTANCE;
  +    }
  +
  +    /**
        * Empty constructor.
        */
       protected FileUtils() {
  @@ -1355,7 +1368,6 @@
       public boolean isUpToDate(long sourceTime, long destTime) {
           return isUpToDate(sourceTime, destTime, 
getFileTimestampGranularity());
       }
  -
   
       /**
        * close a writer without throwing any exception if something went wrong.
  
  
  
  1.14      +4 -4      
ant/src/main/org/apache/tools/ant/types/selectors/MappingSelector.java
  
  Index: MappingSelector.java
  ===================================================================
  RCS file: 
/home/cvs/ant/src/main/org/apache/tools/ant/types/selectors/MappingSelector.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- MappingSelector.java      9 Mar 2004 16:48:47 -0000       1.13
  +++ MappingSelector.java      4 Jan 2005 20:20:52 -0000       1.14
  @@ -1,5 +1,5 @@
   /*
  - * Copyright  2000-2004 The Apache Software Foundation
  + * Copyright  2000-2005 The Apache Software Foundation
    *
    *  Licensed under the Apache License, Version 2.0 (the "License");
    *  you may not use this file except in compliance with the License.
  @@ -40,7 +40,7 @@
        *
        */
       public MappingSelector() {
  -        granularity = (int) 
FileUtils.newFileUtils().getFileTimestampGranularity();
  +        granularity = (int) 
FileUtils.getFileUtils().getFileTimestampGranularity();
       }
   
   
  @@ -128,8 +128,8 @@
   
       /**
        * Sets the number of milliseconds leeway we will give before we consider
  -     * a file out of date. Defaults to 2000 on MS-DOS derivatives as the FAT
  -     * file system.
  +     * a file out of date. Defaults to 2000 on MS-DOS derivatives and 1000 on
  +     * others.
        * @param granularity the leeway in milliseconds
        */
       public void setGranularity(int granularity) {
  
  
  
  1.17      +4 -5      
ant/src/main/org/apache/tools/ant/types/selectors/DateSelector.java
  
  Index: DateSelector.java
  ===================================================================
  RCS file: 
/home/cvs/ant/src/main/org/apache/tools/ant/types/selectors/DateSelector.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- DateSelector.java 16 Dec 2004 15:02:48 -0000      1.16
  +++ DateSelector.java 4 Jan 2005 20:20:52 -0000       1.17
  @@ -1,5 +1,5 @@
   /*
  - * Copyright  2002-2004 The Apache Software Foundation
  + * Copyright  2002-2005 The Apache Software Foundation
    *
    *  Licensed under the Apache License, Version 2.0 (the "License");
    *  you may not use this file except in compliance with the License.
  @@ -27,6 +27,7 @@
   import org.apache.tools.ant.taskdefs.condition.Os;
   import org.apache.tools.ant.types.EnumeratedAttribute;
   import org.apache.tools.ant.types.Parameter;
  +import org.apache.tools.ant.util.FileUtils;
   
   /**
    * Selector that chooses files based on their last modified date.
  @@ -38,7 +39,7 @@
       private long millis = -1;
       private String dateTime = null;
       private boolean includeDirs = false;
  -    private int granularity = 0;
  +    private long granularity = 0;
       private int cmp = 2;
       private String pattern;
       /** Key to used for parameterized custom selector */
  @@ -59,9 +60,7 @@
        *
        */
       public DateSelector() {
  -        if (Os.isFamily("dos")) {
  -            granularity = 2000;
  -        }
  +        granularity = FileUtils.getFileUtils().getFileTimestampGranularity();
       }
   
       /**
  
  
  
  1.79      +3 -3      ant/src/main/org/apache/tools/ant/taskdefs/Copy.java
  
  Index: Copy.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Copy.java,v
  retrieving revision 1.78
  retrieving revision 1.79
  diff -u -r1.78 -r1.79
  --- Copy.java 4 Jan 2005 19:39:01 -0000       1.78
  +++ Copy.java 4 Jan 2005 20:20:52 -0000       1.79
  @@ -1,5 +1,5 @@
   /*
  - * Copyright  2000-2004 The Apache Software Foundation
  + * Copyright  2000-2005 The Apache Software Foundation
    *
    *  Licensed under the Apache License, Version 2.0 (the "License");
    *  you may not use this file except in compliance with the License.
  @@ -84,7 +84,7 @@
        * Copy task constructor.
        */
       public Copy() {
  -        fileUtils = FileUtils.newFileUtils();
  +        fileUtils = FileUtils.getFileUtils();
           granularity = fileUtils.getFileTimestampGranularity();
       }
   
  
  
  
  1.28      +6 -8      ant/src/main/org/apache/tools/ant/taskdefs/DependSet.java
  
  Index: DependSet.java
  ===================================================================
  RCS file: 
/home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/DependSet.java,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- DependSet.java    9 Mar 2004 16:48:04 -0000       1.27
  +++ DependSet.java    4 Jan 2005 20:20:52 -0000       1.28
  @@ -1,5 +1,5 @@
   /*
  - * Copyright  2001-2002,2004 The Apache Software Foundation
  + * Copyright  2001-2005 The Apache Software Foundation
    *
    *  Licensed under the Apache License, Version 2.0 (the "License");
    *  you may not use this file except in compliance with the License.
  @@ -27,6 +27,7 @@
   import org.apache.tools.ant.taskdefs.condition.Os;
   import org.apache.tools.ant.types.FileList;
   import org.apache.tools.ant.types.FileSet;
  +import org.apache.tools.ant.util.FileUtils;
   
   /**
    * Examines and removes out of date target files.  If any of the target files
  @@ -134,13 +135,10 @@
   
           long now = (new Date()).getTime();
           /*
  -          If we're on Windows, we have to munge the time up to 2 secs to
  -          be able to check file modification times.
  -          (Windows has a max resolution of two secs for modification times)
  +          We have to munge the time to allow for the filesystem time
  +          granularity.
           */
  -        if (Os.isFamily("windows")) {
  -            now += 2000;
  -        }
  +        now += FileUtils.getFileUtils().getFileTimestampGranularity();
   
           //
           // Grab all the target files specified via filesets
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to