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.

checksum.html 6.7 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Language" content="en-us">
  4. <title>Checksum Task</title>
  5. </head>
  6. <body>
  7. <h2><a name="checksum">Checksum</a></h2>
  8. <h3>Description</h3>
  9. <p>
  10. Generates checksum for files. This task can also be used to
  11. perform checksum verifications.
  12. </p>
  13. <h3>Parameters</h3>
  14. <table border="1" cellpadding="2" cellspacing="0">
  15. <tr>
  16. <td valign="top"><b>Attribute</b></td>
  17. <td valign="top"><b>Description</b></td>
  18. <td align="center" valign="top"><b>Required</b></td>
  19. </tr>
  20. <tr>
  21. <td valign="top">file</td>
  22. <td valign="top">The file to generate checksum for.</td>
  23. <td valign="top" align="center">One of either <var>file</var> or
  24. at least one nested fileset element.</td>
  25. </tr>
  26. <tr>
  27. <td valign="top">todir</td>
  28. <td valign="top">The root directory where checksums should be written.</td>
  29. <td valign="top" align="center">No. If not specified, checksum files
  30. will be written to the same directory as the files themselves.
  31. <em>since Ant 1.6</em>
  32. </td>
  33. </tr>
  34. <tr>
  35. <td valign="top">algorithm</td>
  36. <td valign="top">Specifies the algorithm to be used to
  37. compute the checksum. Defaults to &quot;MD5&quot;.
  38. Other popular algorithms like &quot;SHA&quot; may be used
  39. as well.
  40. </td>
  41. <td valign="top" align="center">No</td>
  42. </tr>
  43. <tr>
  44. <td valign="top">provider</td>
  45. <td valign="top">Specifies the provider of the algorithm.</td>
  46. <td valign="top" align="center">No</td>
  47. </tr>
  48. <tr>
  49. <td valign="top">fileext</td>
  50. <td valign="top">The generated checksum file's name will be the
  51. original filename with &quot;.&quot; and fileext added to it.
  52. Defaults to the algorithm name being used.
  53. </td>
  54. <td valign="top" align="center">No</td>
  55. </tr>
  56. <tr>
  57. <td valign="top">property</td>
  58. <td valign="top">This attribute can mean two different things, it
  59. depends on the presence of the verifyproperty attribute.<br/>
  60. <b>If you don't set the verifyproperty attribute</b>, property
  61. specifies the name of the property to be set with the generated
  62. checksum value.<br/>
  63. <b>If you set the verifyproperty attribute</b>, property specifies
  64. the checksum you expect to be generated (the checksum itself, not
  65. a name of a property containing the checksum).<br/>
  66. This cannot be specified when fileext is being used or when the
  67. number of files for which checksums is to be generated is greater
  68. than 1.
  69. </td>
  70. <td valign="top" align="center">No</td>
  71. </tr>
  72. <tr>
  73. <td valign="top">totalproperty</td>
  74. <td valign="top">If specified, this attribute specifies the name of
  75. the property that will hold a checksum of all the checksums and
  76. file paths. The individual checksums and the relative paths to
  77. the files within the filesets they are defined in will be used to
  78. compute this checksum. (The file separators in the paths will be
  79. converted to '/' before computation to ensure platform portability).
  80. <em>since Ant 1.6</em>
  81. </td>
  82. <td valign="top" align="center">No</td>
  83. </tr>
  84. <tr>
  85. <td valign="top">forceoverwrite</td>
  86. <td valign="top">Overwrite existing files even if the destination
  87. files are newer. Defaults to &quot;no&quot;.</td>
  88. <td valign="top" align="center">No</td>
  89. </tr>
  90. <tr>
  91. <td valign="top">verifyproperty</td>
  92. <td valign="top">Specifies the name of the property to be set
  93. with &quot;true&quot; or &quot;false&quot; depending upon whether
  94. the generated checksum matches the existing checksum. When
  95. this is set, the generated checksum is not written to a file or
  96. property, but rather, the content of the file or property is used to
  97. check against the generated checksum.
  98. <td valign="top" align="center">No</td>
  99. </tr>
  100. <tr>
  101. <td valign="top">readbuffersize</td>
  102. <td valign="top">The size of the buffer (in bytes) to use when
  103. reading a file. Defaults to &quot;8192&quot; - you may get a
  104. better performance on big files if you increase this value.</td>
  105. <td valign="top" align="center">No</td>
  106. </tr>
  107. </table>
  108. <h3>Parameters specified as nested elements</h3>
  109. <h4>fileset</h4>
  110. <p>
  111. <a href="../CoreTypes/fileset.html">FileSets</a> are used to select files to
  112. generate checksums for.
  113. </p>
  114. <h3>Examples</h3>
  115. <p><b>Example 1</b></p>
  116. <pre>&lt;checksum file=&quot;foo.bar&quot;/&gt;</pre>
  117. Generates a MD5 checksum for foo.bar and stores the checksum in the destination file
  118. foo.bar.MD5. foo.bar.MD5 is overwritten only if foo.bar is newer than itself.
  119. <p><b>Example 2</b></p>
  120. <pre>&lt;checksum file=&quot;foo.bar&quot; forceOverwrite=&quot;yes&quot;/&gt;</pre>
  121. Generates a MD5 checksum for foo.bar and stores the checksum in foo.bar.MD5.
  122. If foo.bar.MD5 already exists, it is overwritten.
  123. <p><b>Example 3</b></p>
  124. <pre>&lt;checksum file=&quot;foo.bar&quot; property=&quot;foobarMD5&quot;/&gt;</pre>
  125. Generates a MD5 checksum for foo.bar and stores it in the Project Property foobarMD5.
  126. <p><b>Example 4</b></p>
  127. <pre>&lt;checksum file=&quot;foo.bar&quot; verifyProperty=&quot;isMD5ok&quot;/&gt;</pre>
  128. Generates a MD5 checksum for foo.bar, compares it against foo.bar.MD5 and sets
  129. isMD5ok to either true or false, depending upon the result.
  130. <p><b>Example 5</b></p>
  131. <pre>&lt;checksum file=&quot;foo.bar&quot; algorithm=&quot;SHA&quot; fileext=&quot;asc&quot;/&gt;</pre>
  132. Generates a SHA checksum for foo.bar and stores the checksum in the destination file
  133. foo.bar.asc. foo.bar.asc is overwritten only if foo.bar is newer than itself.
  134. <p><b>Example 6</b></p>
  135. <pre>
  136. &lt;checksum file=&quot;foo.bar&quot; property=&quot;${md5}&quot; verifyProperty=&quot;isEqual&quot;/&gt;
  137. </pre>
  138. Generates a MD5 checksum for foo.bar, compares it against the value of the property
  139. md5, and sets isEqual to either true or false, depending upon the result.
  140. <p><b>Example 7</b></p>
  141. <pre>
  142. &lt;checksum&gt;
  143. &lt;fileset dir=&quot;.&quot;&gt;
  144. &lt;include name=&quot;foo*&quot;/&gt;
  145. &lt;/fileset&gt;
  146. &lt;/checksum&gt;
  147. </pre>
  148. Works just like Example 1, but generates a .MD5 file for every file that begins with the name foo.
  149. <p><b>Example 8</b></p>
  150. <pre>
  151. &lt;condition property=&quot;isChecksumEqual&quot;&gt;
  152. &lt;checksum&gt;
  153. &lt;fileset dir=&quot;.&quot;&gt;
  154. &lt;include name=&quot;foo.bar&quot;/&gt;
  155. &lt;/fileset&gt;
  156. &lt;/checksum&gt;
  157. &lt;/condition&gt;
  158. </pre>
  159. Works like Example 4, but only sets isChecksumEqual to true, if the
  160. checksum matches - it will never be set to false. This example
  161. demonstrates use with the Condition task.
  162. <h3>Note:</h3>
  163. When working with more than one file, if condition and/or verifyproperty is used,
  164. the result will be true only if the checksums matched correctly for all files being
  165. considered.
  166. <hr><p align="center">Copyright &copy; 2001-2004 The Apache Software Foundation. All rights
  167. Reserved.</p>
  168. </body>
  169. </html>