ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arn...@locus.apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs Tar.java Untar.java
Date Sat, 17 Jun 2000 12:57:49 GMT
arnout      00/06/17 05:57:49

  Modified:    src/main/org/apache/tools/ant/taskdefs Tar.java Untar.java
  Log:
  Fix for Tar-time
  
  Submitted by:	Stefan Bodewig <bodewig@bost.de>
  
  Revision  Changes    Path
  1.2       +1 -1      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Tar.java
  
  Index: Tar.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Tar.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Tar.java	2000/02/10 18:04:29	1.1
  +++ Tar.java	2000/06/17 12:57:48	1.2
  @@ -122,7 +122,7 @@
   
           TarEntry te = new TarEntry(vPath);
           te.setSize(file.length());
  -        te.setModTime(file.lastModified() / 1000);
  +        te.setModTime(file.lastModified());
           tOut.putNextEntry(te);
   
           byte[] buffer = new byte[8 * 1024];
  
  
  
  1.2       +35 -2     jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Untar.java
  
  Index: Untar.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Untar.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Untar.java	2000/05/24 14:35:22	1.1
  +++ Untar.java	2000/06/17 12:57:48	1.2
  @@ -57,6 +57,9 @@
   import org.apache.tools.ant.*;
   import org.apache.tools.tar.*;
   import java.io.*;
  +import java.lang.reflect.InvocationTargetException;
  +import java.lang.reflect.Method;
  +
   /**
    * Untar a file.
    *
  @@ -74,6 +77,23 @@
        * @exception BuildException Thrown in unrecoverable error.
        */
       public void execute() throws BuildException {
  +
  +        Method setLastModified = null;
  +        Long[] times = null;
  +        // 1.0 is ruled out anyway, so this ensures 1.2 or above
  +        if (project.getJavaVersion() != Project.JAVA_1_1) {
  +            try {
  +                setLastModified = 
  +                    java.io.File.class.getMethod("setLastModified", 
  +                                                 new Class[] {Long.TYPE});
  +
  +                times = new Long[1];
  +            } catch (Exception e) {
  +                project.log("File.setLastModified(long) not found",
  +                            Project.MSG_VERBOSE);
  +            }
  +        }
  +                    
           try {
               if (source == null) {
                   throw new BuildException("No source specified");
  @@ -115,8 +135,21 @@
   
                           fos.close();
                       }
  -                } catch( FileNotFoundException ex ) {
  -                    System.out.println("FileNotFoundException: " +  te.getName()  );
  +
  +                    if (setLastModified != null) {
  +                        times[0] = new Long(te.getModTime().getTime());
  +                        try {
  +                            setLastModified.invoke(f, times);
  +                        } catch (Exception e) {
  +                            project.log("cannot invoke File.setLastModified(long)",
  +                                        Project.MSG_VERBOSE);
  +                            setLastModified = null;
  +                        }
  +                    }
  +
  +                } catch(FileNotFoundException ex) {
  +                    project.log("FileNotFoundException: " + te.getName(),
  +                                Project.MSG_WARN);
                   }
               }
           } catch (IOException ioe) {
  
  
  

Mime
View raw message