I'm not familiar with applying ant patches, plus I don't have a strong need for 
the fixcrlf right now, so I'm going to have to postpone any trials for the time 
being...


On Fri, 04 Mar 2005 00:35:58 +0900 (JST), Yuji Yamano <[EMAIL PROTECTED]> wrote:

"michael sorens" <[EMAIL PROTECTED]> writes:

Is it possible to run <fixcrlf> without changing a file's
modification time? Or perhaps a way to use <touch> to restore the
original modification time after the <fixcrlf> (on a group of
files)?  I actually want to run fixcrlf in conjunction with copy
(which has the preservelastmodified attribute to retain the
modification time) but I see no way to do this.

The fixcrlf task doesn't support it yet. Could you try this patch?

Index: FixCRLF.java
===================================================================
RCS file: 
/home/cvspublic/ant/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java,v
retrieving revision 1.64
diff -u -u -r1.64 FixCRLF.java
--- FixCRLF.java        25 Feb 2005 00:33:00 -0000      1.64
+++ FixCRLF.java        3 Mar 2005 15:30:19 -0000
@@ -118,6 +118,7 @@
     private int tabs;
     private boolean javafiles = false;
     private boolean fixlast = true;
+    private boolean preserveLastModified = false;
    private File srcDir;
     private File destDir = null;
@@ -319,6 +320,13 @@
     }
    /**
+     * Set to true if keeping the last modified time as the original files.
+     */
+    public void setPreserveLastModified(boolean preserve) {
+        preserveLastModified = preserve;
+    }
+
+    /**
      * Executes the task.
      */
     public void execute() throws BuildException {
@@ -381,6 +389,7 @@
    private void processFile(String file) throws BuildException {
         File srcFile = new File(srcDir, file);
+        long lastModified = srcFile.lastModified();
         File destD = destDir == null ? srcDir : destDir;
         File tmpFile = null;
         BufferedWriter outWriter;
@@ -557,6 +566,10 @@
            if (destIsWrong) {
                 FILE_UTILS.rename(tmpFile, destFile);
+                if (preserveLastModified) {
+                    log("preserved lastModified", Project.MSG_DEBUG);
+                    FILE_UTILS.setFileLastModified(destFile, lastModified);
+                }
                 tmpFile = null;
             }




--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to