You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

truncate.html 3.7 kB

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