Browse Source

Add preservelastmodified attribute to <ftp>.

PR: 12548
Submitted by:	gudnabrsam at yahoo.com


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@273346 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 23 years ago
parent
commit
c8d4ba2393
2 changed files with 26 additions and 0 deletions
  1. +7
    -0
      docs/manual/OptionalTasks/ftp.html
  2. +19
    -0
      src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java

+ 7
- 0
docs/manual/OptionalTasks/ftp.html View File

@@ -137,6 +137,13 @@ the code to parse MS-DOS listings -any takers?
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>


+ 19
- 0
src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java View File

@@ -128,6 +128,7 @@ public class FTP
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();
@@ -330,6 +331,14 @@ public class FTP
}


/**
* 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 @@ public class FTP
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) {


Loading…
Cancel
Save