Set the length of one or more files, as the intermittently available truncate
Unix
utility/function. In addition to working with a single file, this Task can also work
on resources and resource collections. Since Apache Ant
1.7.1.
Attribute | Description | Required |
---|---|---|
file | The name of the file. | Unless a nested resource collection element has been specified |
length | Specifies the new file length (in bytes) to set. The following suffixes are supported:
|
At most one of these; omitting both implies length=0 |
adjust | Specifies the number of bytes (and positive/negative direction) by which to adjust file lengths. The same suffixes are supported for this attribute as for the length attribute. | |
create | Whether to create nonexistent files. | No; default true |
mkdirs | Whether to create nonexistent parent directories when creating new files. | No; default false |
You can use any number of nested resource collection elements to define the resources for this task and refer to resources defined elsewhere. Note: resources passed to this task are expected to be filesystem-based.
<truncate file="foo"/>
Sets the length of file foo to zero.
<truncate file="foo" length="1K"/>
Sets the length of file foo to 1 kilobyte (1024 bytes).
<truncate file="foo" adjust="1K"/>
Adjusts the length of file foo upward by 1 kilobyte.
<truncate file="foo" adjust="-1M"/>
Adjusts the length of file foo downward by 1 megabyte.