| 1 |
<!DOCTYPE html> |
| 2 |
<!-- |
| 3 |
Licensed to the Apache Software Foundation (ASF) under one or more |
| 4 |
contributor license agreements. See the NOTICE file distributed with |
| 5 |
this work for additional information regarding copyright ownership. |
| 6 |
The ASF licenses this file to You under the Apache License, Version 2.0 |
| 7 |
(the "License"); you may not use this file except in compliance with |
| 8 |
the License. You may obtain a copy of the License at |
| 9 |
|
| 10 |
https://www.apache.org/licenses/LICENSE-2.0 |
| 11 |
|
| 12 |
Unless required by applicable law or agreed to in writing, software |
| 13 |
distributed under the License is distributed on an "AS IS" BASIS, |
| 14 |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 |
See the License for the specific language governing permissions and |
| 16 |
limitations under the License. |
| 17 |
--> |
| 18 |
<html lang="en"> |
| 19 |
|
| 20 |
<head> |
| 21 |
<link rel="stylesheet" type="text/css" href="../stylesheets/style.css"> |
| 22 |
<title>Truncate Task</title> |
| 23 |
</head> |
| 24 |
|
| 25 |
<body> |
| 26 |
|
| 27 |
<h2 id="touch">Truncate</h2> |
| 28 |
<p><em>Since Apache Ant 1.7.1</em></p> |
| 29 |
<h3>Description</h3> |
| 30 |
|
| 31 |
<p>Set the length of one or more files, as the <code>truncate</code> Unix function or GNU |
| 32 |
utility. In addition to working with a single file, this Task can also work |
| 33 |
on <a href="../Types/resources.html">resources</a> and resource collections.</p> |
| 34 |
|
| 35 |
<h3>Parameters</h3> |
| 36 |
<table class="attr"> |
| 37 |
<tr> |
| 38 |
<th scope="col">Attribute</th> |
| 39 |
<th scope="col">Description</th> |
| 40 |
<th scope="col">Required</th> |
| 41 |
</tr> |
| 42 |
<tr> |
| 43 |
<td>file</td> |
| 44 |
<td>The name of the file.</td> |
| 45 |
<td>Unless a nested resource collection element has been specified</td> |
| 46 |
</tr> |
| 47 |
<tr> |
| 48 |
<td>length</td> |
| 49 |
<td>Specifies the new file length (in bytes) to set. The following suffixes are supported: |
| 50 |
<ul> |
| 51 |
<li><q>K</q> : Kilobytes (1024 bytes)</li> |
| 52 |
<li><q>M</q> : Megabytes (1024 K)</li> |
| 53 |
<li><q>G</q> : Gigabytes (1024 M)</li> |
| 54 |
<li><q>T</q> : Terabytes (1024 G)</li> |
| 55 |
<li><q>P</q> : Petabytes (1024 T)</li> |
| 56 |
</ul> |
| 57 |
</td> |
| 58 |
<td rowspan="2">At most one of these; omitting both implies <var>length</var>=<q>0</q> |
| 59 |
</td> |
| 60 |
</tr> |
| 61 |
<tr> |
| 62 |
<td>adjust</td> |
| 63 |
<td class="left">Specifies the number of bytes (and positive/negative direction) by which to |
| 64 |
adjust file lengths. The same suffixes are supported for this attribute as for |
| 65 |
the <var>length</var> attribute. |
| 66 |
</td> |
| 67 |
</tr> |
| 68 |
<tr> |
| 69 |
<td>create</td> |
| 70 |
<td>Whether to create nonexistent files.</td> |
| 71 |
<td>No; default <q>true</q></td> |
| 72 |
</tr> |
| 73 |
<tr> |
| 74 |
<td>mkdirs</td> |
| 75 |
<td>Whether to create nonexistent parent directories when creating new files.</td> |
| 76 |
<td>No; default <q>false</q></td> |
| 77 |
</tr> |
| 78 |
</table> |
| 79 |
<h3>Parameters specified as nested elements</h3> |
| 80 |
<h4>any resource collection</h4> |
| 81 |
|
| 82 |
<p>You can use any number of nested resource collection elements to define the resources for this |
| 83 |
task and refer to resources defined elsewhere. <strong>Note</strong>: resources passed to this task |
| 84 |
are expected to be filesystem-based.</p> |
| 85 |
|
| 86 |
<h3>Examples</h3> |
| 87 |
|
| 88 |
<p>Set the length of file <samp>foo</samp> to zero.</p> |
| 89 |
<pre><truncate file="foo"/></pre> |
| 90 |
|
| 91 |
<p>Set the length of file <samp>foo</samp> to 1 kilobyte (1024 bytes).</p> |
| 92 |
<pre><truncate file="foo" length="1K"/></pre> |
| 93 |
|
| 94 |
<p>Adjust the length of file <samp>foo</samp> upward by 1 kilobyte.</p> |
| 95 |
<pre><truncate file="foo" adjust="1K"/></pre> |
| 96 |
|
| 97 |
<p>Adjust the length of file <samp>foo</samp> downward by 1 megabyte.</p> |
| 98 |
<pre><truncate file="foo" adjust="-1M"/></pre> |
| 99 |
|
| 100 |
</body> |
| 101 |
</html> |