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.8 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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="../Types/resources.html">resources</a> and resource collections.
  28. <strong>Since Apache 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 (in bytes) to set.
  46. The following 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">At most one of these.
  56. Omitting both implies <code>length="0"</code>.
  57. </td>
  58. </tr>
  59. <tr>
  60. <td valign="top">adjust</td>
  61. <td valign="top">Specifies the number of bytes
  62. (and positive/negative direction)
  63. by which to adjust file lengths. The same suffixes are supported
  64. for this attribute as for the <code>length</code> attribute.
  65. </td>
  66. </tr>
  67. <tr>
  68. <td valign="top">create</td>
  69. <td valign="top">Whether to create nonexistent files.</td>
  70. <td valign="top" align="center">No, default <i>true</i>.</td>
  71. </tr>
  72. <tr>
  73. <td valign="top">mkdirs</td>
  74. <td valign="top">Whether to create nonexistent parent
  75. directories when creating new files.</td>
  76. <td valign="top" align="center">No, default <i>false</i>.</td>
  77. </tr>
  78. </table>
  79. <h3>Parameters specified as nested elements</h3>
  80. <h4>any resource collection</h4>
  81. <p>You can use any number of nested resource collection elements to
  82. define the resources for this task and refer to resources defined
  83. elsewhere. <b>Note:</b> resources passed to this task are expected
  84. to be filesystem-based.</p>
  85. <h3>Examples</h3>
  86. <pre> &lt;truncate file="foo" /&gt;</pre>
  87. <p>Sets the length of file <code>foo</code> to zero.</p>
  88. <pre> &lt;truncate file="foo" length="1K" /&gt;</pre>
  89. <p>Sets the length of file <code>foo</code> to 1 kilobyte (1024 bytes).</p>
  90. <pre> &lt;truncate file="foo" adjust="1K" /&gt;</pre>
  91. <p>Adjusts the length of file <code>foo</code> upward by 1 kilobyte.</p>
  92. <pre> &lt;truncate file="foo" adjust="-1M" /&gt;</pre>
  93. <p>Adjusts the length of file <code>foo</code> downward by 1 megabyte.</p>
  94. </body>
  95. </html>