ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/net FTP.java
Date Mon, 23 Sep 2002 15:47:56 GMT
bodewig     2002/09/23 08:47:56

  Modified:    docs/manual/OptionalTasks ftp.html
               src/main/org/apache/tools/ant/taskdefs/optional/net FTP.java
  Log:
  Add preservelastmodified attribute to <ftp>.
  
  PR: 12548
  Submitted by:	gudnabrsam at yahoo.com
  
  Revision  Changes    Path
  1.13      +7 -0      jakarta-ant/docs/manual/OptionalTasks/ftp.html
  
  Index: ftp.html
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/docs/manual/OptionalTasks/ftp.html,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- ftp.html	4 Sep 2002 11:05:18 -0000	1.12
  +++ ftp.html	23 Sep 2002 15:47:55 -0000	1.13
  @@ -137,6 +137,13 @@
       remainder of the files still transferred. Default: false</td>
       <td valign="top" align="center">No</td>
     </tr>  
  +  <tr>
  +    <td valign="top">preservelastmodified</td>
  +    <td valign="top">Give the copied files the same last modified
  +      time as the original source files (applies to getting files only).
  +      (<em>Note</em>: Ignored on Java 1.1)</td>
  +    <td valign="top" align="center">No; defaults to false.</td>
  +  </tr>
   </table>
   <h3>Sending Files</h3>
   <p>The easiest way to describe how to send files is with a couple of examples:</p>
  
  
  
  1.27      +19 -0     jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java
  
  Index: FTP.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- FTP.java	25 Jul 2002 15:21:18 -0000	1.26
  +++ FTP.java	23 Sep 2002 15:47:56 -0000	1.27
  @@ -128,6 +128,7 @@
       private boolean skipFailedTransfers = false;
       private int skipped = 0;
       private boolean ignoreNoncriticalErrors = false;
  +    private boolean preserveLastModified = false;
       private String chmod = null;
       private String umask = null;
       private FileUtils fileUtils = FileUtils.newFileUtils();
  @@ -331,6 +332,14 @@
   
   
       /**
  +     * Set to true to preserve modification times for "gotten" files.
  +     */
  +    public void setPreserveLastModified(boolean preserveLastModified) {
  +        this.preserveLastModified = preserveLastModified;
  +    }
  +
  +
  +    /**
        * Set to true to transmit only files that are new or changed from their
        * remote counterparts. The default is to transmit all files.
        */
  @@ -822,6 +831,16 @@
                   log("File " + file.getAbsolutePath() + " copied from "
                        + server, Project.MSG_VERBOSE);
                   transferred++;
  +                if (preserveLastModified) {
  +                    outstream.close();
  +                    outstream = null;
  +                    FTPFile[] remote = ftp.listFiles(resolveFile(filename));
  +                    if (remote.length > 0) {
  +                        fileUtils.setFileLastModified(file,
  +                                                      remote[0].getTimestamp()
  +                                                      .getTime().getTime());
  +                    }
  +                }
               }
           } finally {
               if (outstream != null) {
  
  
  

--
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