diff --git a/docs/manual/OptionalTasks/ftp.html b/docs/manual/OptionalTasks/ftp.html index b0b07e005..2db8a5912 100644 --- a/docs/manual/OptionalTasks/ftp.html +++ b/docs/manual/OptionalTasks/ftp.html @@ -137,6 +137,13 @@ the code to parse MS-DOS listings -any takers? remainder of the files still transferred. Default: false
The easiest way to describe how to send files is with a couple of examples:
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java b/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java index 7870260a4..f2734ffa7 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java @@ -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) {