Source files and directories are only deleted when the file or directory has been copied to the destination successfully. Filtering also works.
This implementation is based on Arnout Kuiper's initial design document, the following mailing list discussions, and the copyfile/copydir tasks.
| Modifier and Type | Field and Description |
|---|---|
| private boolean |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| private void | |
| protected void | |
| protected void | |
| protected void | doFileOperations()
Overrides org. |
| private void | |
| protected boolean | Returns: true if a deletion can go aheadthe directory to check d)Its only ok to delete a directory tree if there are no files in it. |
| protected boolean | Returns: true if the file was renamedthe file to rename sourceFile, File the destination file destFile, boolean if true, filtering is in operation, file will
be copied/deleted instead of renamed filtering, boolean if true force overwrite even if destination file
is newer than source file overwrite)Attempts to rename a file from a source to a destination. |
| public void | setPerformGcOnFailedDelete(boolean
boolean b)Whether to perform a garbage collection before retrying a failed delete. |
| protected void | validateAttributes()
Overrides org. |
| performGc | back to summary |
|---|---|
| private boolean performGc | |
| Move | back to summary |
|---|---|
| public Move() Constructor of object. This sets the forceOverwrite attribute of the Copy parent class to true. | |
| copyFile | back to summary |
|---|---|
| private void copyFile(File fromFile, File toFile, boolean filtering, boolean overwrite) Copy fromFile to toFile. | |
| deleteDir | back to summary |
|---|---|
| protected void deleteDir(File d) Go and delete the directory tree.
| |
| deleteDir | back to summary |
|---|---|
| protected void deleteDir(File d, boolean deleteFiles) Go and delete the directory tree.
| |
| doFileOperations | back to summary |
|---|---|
| protected void doFileOperations() Overrides org. Override copy's doFileOperations to move the files instead of copying them.
| |
| moveFile | back to summary |
|---|---|
| private void moveFile(File fromFile, File toFile, boolean filtering, boolean overwrite) Try to move the file via a rename, but if this fails or filtering is enabled, copy the file then delete the sourceFile. | |
| okToDelete | back to summary |
|---|---|
| protected boolean okToDelete(File d) Its only ok to delete a directory tree if there are no files in it.
| |
| renameFile | back to summary |
|---|---|
| protected boolean renameFile(File sourceFile, File destFile, boolean filtering, boolean overwrite) throws IOException, BuildException Attempts to rename a file from a source to a destination. If overwrite is set to true, this method overwrites existing file even if the destination file is newer. Otherwise, the source file is renamed only if the destination file is older than it. Method then checks if token filtering is used. If it is, this method returns false assuming it is the responsibility to the copyFile method.
| |
| setPerformGcOnFailedDelete | back to summary |
|---|---|
| public void setPerformGcOnFailedDelete(boolean b) Whether to perform a garbage collection before retrying a failed delete. This may be required on Windows (where it is set to true by default) but also on other operating systems, for example when deleting directories from an NFS share.
| |
| validateAttributes | back to summary |
|---|---|
| protected void validateAttributes() throws BuildException Overrides org. Doc from org. Ensure we have a consistent and legal set of attributes, and set any internal flags necessary based on different combinations of attributes..
| |