public class Move extends Copy
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.
completeDirMap, destDir, destFile, dirCopyMap, failonerror, file, fileCopyMap, filesets, fileUtils, filtering, flatten, forceOverwrite, includeEmpty, mapperElement, preserveLastModified, rcs, verbosity
Constructor and Description |
---|
Move()
Constructor of object.
|
Modifier and Type | Method and Description |
---|---|
protected void |
deleteDir(File d)
Go and delete the directory tree.
|
protected void |
deleteDir(File d,
boolean deleteFiles)
Go and delete the directory tree.
|
protected void |
doFileOperations()
Override copy's doFileOperations to move the files instead of copying them.
|
protected boolean |
okToDelete(File d)
Its only ok to delete a directory tree if there are no files in it.
|
protected boolean |
renameFile(File sourceFile,
File destFile,
boolean filtering,
boolean overwrite)
Attempts to rename a file from a source to a destination.
|
void |
setPerformGcOnFailedDelete(boolean b)
Whether to perform a garbage collection before retrying a failed delete.
|
protected void |
validateAttributes()
Ensure we have a consistent and legal set of attributes, and set
any internal flags necessary based on different combinations
of attributes.
|
add, add, addFileset, buildMap, buildMap, createFilterChain, createFilterSet, createMapper, doResourceOperations, execute, getEncoding, getFileUtils, getFilterChains, getFilterSets, getForce, getOutputEncoding, getPreserveLastModified, isEnableMultipleMapping, scan, scan, setEnableMultipleMappings, setEncoding, setFailOnError, setFile, setFiltering, setFlatten, setForce, setGranularity, setIncludeEmptyDirs, setOutputEncoding, setOverwrite, setPreserveLastModified, setQuiet, setTodir, setTofile, setVerbose, supportsNonFileResources
bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
clone, getDescription, getLocation, getProject, setDescription, setLocation, setProject
public Move()
protected void deleteDir(File d)
d
- the directory to deleteprotected void deleteDir(File d, boolean deleteFiles)
d
- the directory to deletedeleteFiles
- whether to delete filesprotected void doFileOperations()
doFileOperations
in class Copy
protected boolean okToDelete(File d)
d
- the directory to checkprotected boolean renameFile(File sourceFile, File destFile, boolean filtering, boolean overwrite) throws IOException, BuildException
sourceFile
- the file to renamedestFile
- the destination filefiltering
- if true, filtering is in operation, file will
be copied/deleted instead of renamedoverwrite
- if true force overwrite even if destination file
is newer than source fileIOException
- if an error occursBuildException
- if an error occurspublic void setPerformGcOnFailedDelete(boolean b)
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.
protected void validateAttributes() throws BuildException
validateAttributes
in class Copy
BuildException
- if an error occurs.