ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/util FileUtils.java
Date Mon, 17 Dec 2001 09:57:28 GMT
donaldp     01/12/17 01:57:28

  Modified:    proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs
                        Expand.java Touch.java
               proposal/myrmidon/src/main/org/apache/tools/ant/util
                        FileUtils.java
  Log:
  setLastModified is availablae in JDK1.2+ !
  
  Revision  Changes    Path
  1.5       +1 -1      jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Expand.java
  
  Index: Expand.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Expand.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Expand.java	2001/12/16 02:05:41	1.4
  +++ Expand.java	2001/12/17 09:57:28	1.5
  @@ -291,7 +291,7 @@
                   }
               }
   
  -            fileUtils.setFileLastModified( f, entryDate.getTime() );
  +            f.setLastModified( entryDate.getTime() );
           }
           catch( FileNotFoundException ex )
           {
  
  
  
  1.4       +2 -2      jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Touch.java
  
  Index: Touch.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Touch.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Touch.java	2001/12/16 00:38:01	1.3
  +++ Touch.java	2001/12/17 09:57:28	1.4
  @@ -214,7 +214,7 @@
               return;
           }
   
  -        fileUtils.setFileLastModified( file, millis );
  +        final long time = ( millis < 0 ) ? System.currentTimeMillis() : millis;
  +        file.setLastModified( time );
       }
  -
   }
  
  
  
  1.4       +3 -82     jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/util/FileUtils.java
  
  Index: FileUtils.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/util/FileUtils.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- FileUtils.java	2001/12/16 00:39:05	1.3
  +++ FileUtils.java	2001/12/17 09:57:28	1.4
  @@ -17,13 +17,11 @@
   import java.io.FileWriter;
   import java.io.IOException;
   import java.io.InputStream;
  -import java.lang.reflect.Method;
   import java.text.DecimalFormat;
   import java.util.Random;
   import java.util.Stack;
   import java.util.StringTokenizer;
   import org.apache.myrmidon.api.TaskException;
  -import org.apache.tools.ant.Project;
   import org.apache.tools.ant.types.FilterSetCollection;
   
   /**
  @@ -34,19 +32,18 @@
    * @author duncan@x180.com
    * @author <a href="mailto:conor@apache.org">Conor MacNeill</a>
    * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
  - * @version $Revision: 1.3 $
  + * @version $Revision: 1.4 $
    */
   
   public class FileUtils
   {
       private static Random rand = new Random( System.currentTimeMillis() );
       private static Object lockReflection = new Object();
  -    private static java.lang.reflect.Method setLastModified = null;
   
       /**
        * Empty constructor.
        */
  -    protected FileUtils()
  +    private FileUtils()
       {
       }
   
  @@ -61,47 +58,6 @@
       }
   
       /**
  -     * Calls File.setLastModified(long time) in a Java 1.1 compatible way.
  -     *
  -     * @param file The new FileLastModified value
  -     * @param time The new FileLastModified value
  -     * @exception TaskException Description of Exception
  -     */
  -    public void setFileLastModified( File file, long time )
  -        throws TaskException
  -    {
  -        if( Project.getJavaVersion() == Project.JAVA_1_1 )
  -        {
  -            return;
  -        }
  -        Long[] times = new Long[ 1 ];
  -        if( time < 0 )
  -        {
  -            times[ 0 ] = new Long( System.currentTimeMillis() );
  -        }
  -        else
  -        {
  -            times[ 0 ] = new Long( time );
  -        }
  -
  -        try
  -        {
  -            getSetLastModified().invoke( file, times );
  -        }
  -        catch( java.lang.reflect.InvocationTargetException ite )
  -        {
  -            Throwable nested = ite.getTargetException();
  -            throw new TaskException( "Exception setting the modification time "
  -                                     + "of " + file, nested );
  -        }
  -        catch( Throwable other )
  -        {
  -            throw new TaskException( "Exception setting the modification time "
  -                                     + "of " + file, other );
  -        }
  -    }
  -
  -    /**
        * Emulation of File.getParentFile for JDK 1.1
        *
        * @param f Description of Parameter
  @@ -395,7 +351,7 @@
   
               if( preserveLastModified )
               {
  -                setFileLastModified( destFile, sourceFile.lastModified() );
  +                destFile.setLastModified( sourceFile.lastModified() );
               }
           }
       }
  @@ -641,41 +597,6 @@
           }
   
           return new File( helpFile.getAbsolutePath() );
  -    }
  -
  -    /**
  -     * see whether we have a setLastModified method in File and return it.
  -     *
  -     * @return The SetLastModified value
  -     */
  -    protected final Method getSetLastModified()
  -        throws TaskException
  -    {
  -        if( Project.getJavaVersion() == Project.JAVA_1_1 )
  -        {
  -            return null;
  -        }
  -        if( setLastModified == null )
  -        {
  -            synchronized( lockReflection )
  -            {
  -                if( setLastModified == null )
  -                {
  -                    try
  -                    {
  -                        setLastModified =
  -                            java.io.File.class.getMethod( "setLastModified",
  -                                                          new Class[]{Long.TYPE} );
  -                    }
  -                    catch( NoSuchMethodException nse )
  -                    {
  -                        throw new TaskException( "File.setlastModified not in JDK >
1.1?",
  -                                                 nse );
  -                    }
  -                }
  -            }
  -        }
  -        return setLastModified;
       }
   }
   
  
  
  

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message