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

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