org.rhq.enterprise.agent.update
Class CopyWithBackup
java.lang.Object
org.apache.tools.ant.ProjectComponent
org.apache.tools.ant.Task
org.rhq.enterprise.agent.update.CopyWithBackup
- All Implemented Interfaces:
- java.lang.Cloneable
public class CopyWithBackup
- extends org.apache.tools.ant.Task
Compares two files, an old one and a new one and if they differ, one will win and be kept as-is
in the new file's parent directory while the other one will get copied under a new name in
the new file's parent directory as a backup copy.
If the two files are identical, this task is a no-op and does nothing.
If backupextension is not specified, the file that is not to be kept will not be backed up.
That will compare old/file to new/file and if they are different, the new one will be kept
as is in directory new and the old one will be copied into directory
'new' but with a name of "file" appended with the backup extension ".default".
The "old" file is always copied to the directory where the "new" file is located; the "keep" attribute
determines which file gets renamed with the backup extension and which keeps its file name intact.
This allows us to tell which customized files from an old install should override the new install's
default files and which of the new default files should override any previous customizations made
to an old install.
This loads in the content of both files to generate the MD5 - do not use this task on large binary
files. If we need to do this kind of task on files other than small text files, we need to refactor
the way the MD5's are calculated.
- Author:
- John Mazzitelli
| Fields inherited from class org.apache.tools.ant.Task |
target, taskName, taskType, wrapper |
| Fields inherited from class org.apache.tools.ant.ProjectComponent |
description, location, project |
| Methods inherited from class org.apache.tools.ant.Task |
bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType |
| Methods inherited from class org.apache.tools.ant.ProjectComponent |
clone, getDescription, getLocation, getProject, setDescription, setLocation, setProject |
| Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
CopyWithBackup
public CopyWithBackup()
setOlddir
public void setOlddir(java.io.File dir)
setNewdir
public void setNewdir(java.io.File dir)
setFilename
public void setFilename(java.lang.String filename)
setKeep
public void setKeep(java.lang.String keep)
setBackupextension
public void setBackupextension(java.lang.String ext)
setFailonerror
public void setFailonerror(java.lang.Boolean flag)
execute
public void execute()
throws org.apache.tools.ant.BuildException
- Overrides:
execute in class org.apache.tools.ant.Task
- Throws:
org.apache.tools.ant.BuildException- See Also:
Task.execute()
Copyright © 2008-2009 Red Hat, Inc.. All Rights Reserved.