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.

unpack.html 4.0 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>GUnzip/BUnzip2 Task</title>
  20. </head>
  21. <body>
  22. <h2 id="unpack">GUnzip/BUnzip2/UnXZ</h2>
  23. <h3>Description</h3>
  24. <p>Expands a resource packed using GZip, BZip2 or XZ.</p>
  25. <p>If <var>dest</var> is a directory the name of the destination file is the same as <var>src</var>
  26. (with the <q>.gz</q>, <q>.bz2</q> or <q>.xz</q> extension removed if present). If <var>dest</var> is
  27. omitted, the parent dir of <var>src</var> is taken. The file is only expanded if the source resource
  28. is newer than the destination file, or when the destination file does not exist.</p>
  29. <p>XZ compression support has been added <em>since Apache Ant 1.10.1</em> and depends on external
  30. libraries not included in the Ant distribution.
  31. See <a href="../install.html#librarydependencies">Library Dependencies</a> for more information.</p>
  32. <h3>Parameters</h3>
  33. <table class="attr">
  34. <tr>
  35. <th scope="col">Attribute</th>
  36. <th scope="col">Description</th>
  37. <th scope="col">Required</th>
  38. </tr>
  39. <tr>
  40. <td>src</td>
  41. <td>the file to expand.</td>
  42. <td>Yes, or a nested resource collection</td>
  43. </tr>
  44. <tr>
  45. <td>dest</td>
  46. <td>the destination file or directory.</td>
  47. <td>No</td>
  48. </tr>
  49. </table>
  50. <h3>Parameters specified as nested elements</h3>
  51. <h4>any <a href="../Types/resources.html">resource</a> or single element resource collection</h4>
  52. <p>The specified resource will be used as <var>src</var>.</p>
  53. <h3>Examples</h3>
  54. <p>Expand <samp>test.tar.gz</samp> to <samp>test.tar</samp></p>
  55. <pre>&lt;gunzip src=&quot;test.tar.gz&quot;/&gt;</pre>
  56. <p>Expand <samp>test.tar.bz2</samp> to <samp>test.tar</samp></p>
  57. <pre>&lt;bunzip2 src=&quot;test.tar.bz2&quot;/&gt;</pre>
  58. <p>Expand <samp>test.tar.xz</samp> to <samp>test.tar</samp></p>
  59. <pre>&lt;unxz src=&quot;test.tar.xz&quot;/&gt;</pre>
  60. <p>Expand <samp>test.tar.gz</samp> to <samp>test2.tar</samp></p>
  61. <pre>&lt;gunzip src=&quot;test.tar.gz&quot; dest=&quot;test2.tar&quot;/&gt;</pre>
  62. <p>Expand <samp>test.tar.gz</samp> to <samp>subdir/test.tar</samp> (assuming <samp>subdir</samp> is
  63. a directory).</p>
  64. <pre>&lt;gunzip src=&quot;test.tar.gz&quot; dest=&quot;subdir&quot;/&gt;</pre>
  65. <p>Download <samp>http://example.org/archive.tar.gz</samp> and expand it to <samp>archive.tar</samp>
  66. in the project's <var>basedir</var> on the fly.</p>
  67. <pre>
  68. &lt;gunzip dest=&quot;.&quot;&gt;
  69. &lt;url url="http://example.org/archive.tar.gz"/&gt;
  70. &lt;/gunzip&gt;
  71. </pre>
  72. <h3>Related tasks</h3>
  73. <p>The following</p>
  74. <pre>&lt;gunzip src="some-archive.gz" dest="some-dest-dir"/&gt;</pre>
  75. <p>is identical to</p>
  76. <pre>
  77. &lt;copy todir="some-dest-dir"&gt;
  78. &lt;gzipresource&gt;
  79. &lt;file file="some-archive.gz"/&gt;
  80. &lt;/gzipresource&gt;
  81. &lt;mapper type="glob" from="*.gz" to="*"/&gt;
  82. &lt;/copy&gt;</pre>
  83. <p>The same is also true for <code>&lt;bunzip2&gt;</code> and <code>&lt;bzip2resource&gt;</code>
  84. or <code>&lt;unxz&gt;</code> and <code>&lt;xzresource&gt;</code>. <code>&lt;copy&gt;</code> offers
  85. additional features like <a href="../Types/filterchain.html">filtering files</a> on the fly,
  86. allowing a file to be mapped to multiple destinations, preserving the last modified time or a
  87. configurable file system timestamp granularity.</p>
  88. </body>
  89. </html>