TarUtils.html 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <!-- NewPage -->
  3. <html lang="de">
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  6. <title>TarUtils (Apache Commons Compress 1.13 API)</title>
  7. <link rel="stylesheet" type="text/css" href="../../../../../../stylesheet.css" title="Style">
  8. </head>
  9. <body>
  10. <script type="text/javascript"><!--
  11. try {
  12. if (location.href.indexOf('is-external=true') == -1) {
  13. parent.document.title="TarUtils (Apache Commons Compress 1.13 API)";
  14. }
  15. }
  16. catch(err) {
  17. }
  18. //-->
  19. </script>
  20. <noscript>
  21. <div>JavaScript is disabled on your browser.</div>
  22. </noscript>
  23. <!-- ========= START OF TOP NAVBAR ======= -->
  24. <div class="topNav"><a name="navbar_top">
  25. <!-- -->
  26. </a><a href="#skip-navbar_top" title="Skip navigation links"></a><a name="navbar_top_firstrow">
  27. <!-- -->
  28. </a>
  29. <ul class="navList" title="Navigation">
  30. <li><a href="../../../../../../overview-summary.html">Overview</a></li>
  31. <li><a href="package-summary.html">Package</a></li>
  32. <li class="navBarCell1Rev">Class</li>
  33. <li><a href="class-use/TarUtils.html">Use</a></li>
  34. <li><a href="package-tree.html">Tree</a></li>
  35. <li><a href="../../../../../../deprecated-list.html">Deprecated</a></li>
  36. <li><a href="../../../../../../index-all.html">Index</a></li>
  37. <li><a href="../../../../../../help-doc.html">Help</a></li>
  38. </ul>
  39. </div>
  40. <div class="subNav">
  41. <ul class="navList">
  42. <li><a href="../../../../../../org/apache/commons/compress/archivers/tar/TarConstants.html" title="interface in org.apache.commons.compress.archivers.tar"><span class="strong">Prev Class</span></a></li>
  43. <li>Next Class</li>
  44. </ul>
  45. <ul class="navList">
  46. <li><a href="../../../../../../index.html?org/apache/commons/compress/archivers/tar/TarUtils.html" target="_top">Frames</a></li>
  47. <li><a href="TarUtils.html" target="_top">No Frames</a></li>
  48. </ul>
  49. <ul class="navList" id="allclasses_navbar_top">
  50. <li><a href="../../../../../../allclasses-noframe.html">All Classes</a></li>
  51. </ul>
  52. <div>
  53. <script type="text/javascript"><!--
  54. allClassesLink = document.getElementById("allclasses_navbar_top");
  55. if(window==top) {
  56. allClassesLink.style.display = "block";
  57. }
  58. else {
  59. allClassesLink.style.display = "none";
  60. }
  61. //-->
  62. </script>
  63. </div>
  64. <div>
  65. <ul class="subNavList">
  66. <li>Summary:&nbsp;</li>
  67. <li>Nested&nbsp;|&nbsp;</li>
  68. <li>Field&nbsp;|&nbsp;</li>
  69. <li>Constr&nbsp;|&nbsp;</li>
  70. <li><a href="#method_summary">Method</a></li>
  71. </ul>
  72. <ul class="subNavList">
  73. <li>Detail:&nbsp;</li>
  74. <li>Field&nbsp;|&nbsp;</li>
  75. <li>Constr&nbsp;|&nbsp;</li>
  76. <li><a href="#method_detail">Method</a></li>
  77. </ul>
  78. </div>
  79. <a name="skip-navbar_top">
  80. <!-- -->
  81. </a></div>
  82. <!-- ========= END OF TOP NAVBAR ========= -->
  83. <!-- ======== START OF CLASS DATA ======== -->
  84. <div class="header">
  85. <div class="subTitle">org.apache.commons.compress.archivers.tar</div>
  86. <h2 title="Class TarUtils" class="title">Class TarUtils</h2>
  87. </div>
  88. <div class="contentContainer">
  89. <ul class="inheritance">
  90. <li><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">java.lang.Object</a></li>
  91. <li>
  92. <ul class="inheritance">
  93. <li>org.apache.commons.compress.archivers.tar.TarUtils</li>
  94. </ul>
  95. </li>
  96. </ul>
  97. <div class="description">
  98. <ul class="blockList">
  99. <li class="blockList">
  100. <hr>
  101. <br>
  102. <pre>public class <a href="../../../../../../src-html/org/apache/commons/compress/archivers/tar/TarUtils.html#line.36">TarUtils</a>
  103. extends <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a></pre>
  104. <div class="block">This class provides static utility methods to work with byte streams.</div>
  105. <dl><dt><span class="strong">This class is immutable</span></dt>
  106. <dd></dd></dl>
  107. </li>
  108. </ul>
  109. </div>
  110. <div class="summary">
  111. <ul class="blockList">
  112. <li class="blockList">
  113. <!-- ========== METHOD SUMMARY =========== -->
  114. <ul class="blockList">
  115. <li class="blockList"><a name="method_summary">
  116. <!-- -->
  117. </a>
  118. <h3>Method Summary</h3>
  119. <table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation">
  120. <caption><span>Methods</span><span class="tabEnd">&nbsp;</span></caption>
  121. <tr>
  122. <th class="colFirst" scope="col">Modifier and Type</th>
  123. <th class="colLast" scope="col">Method and Description</th>
  124. </tr>
  125. <tr class="altColor">
  126. <td class="colFirst"><code>static long</code></td>
  127. <td class="colLast"><code><strong><a href="../../../../../../org/apache/commons/compress/archivers/tar/TarUtils.html#computeCheckSum(byte[])">computeCheckSum</a></strong>(byte[]&nbsp;buf)</code>
  128. <div class="block">Compute the checksum of a tar entry header.</div>
  129. </td>
  130. </tr>
  131. <tr class="rowColor">
  132. <td class="colFirst"><code>static int</code></td>
  133. <td class="colLast"><code><strong><a href="../../../../../../org/apache/commons/compress/archivers/tar/TarUtils.html#formatCheckSumOctalBytes(long,%20byte[],%20int,%20int)">formatCheckSumOctalBytes</a></strong>(long&nbsp;value,
  134. byte[]&nbsp;buf,
  135. int&nbsp;offset,
  136. int&nbsp;length)</code>
  137. <div class="block">Writes an octal value into a buffer.</div>
  138. </td>
  139. </tr>
  140. <tr class="altColor">
  141. <td class="colFirst"><code>static int</code></td>
  142. <td class="colLast"><code><strong><a href="../../../../../../org/apache/commons/compress/archivers/tar/TarUtils.html#formatLongOctalBytes(long,%20byte[],%20int,%20int)">formatLongOctalBytes</a></strong>(long&nbsp;value,
  143. byte[]&nbsp;buf,
  144. int&nbsp;offset,
  145. int&nbsp;length)</code>
  146. <div class="block">Write an octal long integer into a buffer.</div>
  147. </td>
  148. </tr>
  149. <tr class="rowColor">
  150. <td class="colFirst"><code>static int</code></td>
  151. <td class="colLast"><code><strong><a href="../../../../../../org/apache/commons/compress/archivers/tar/TarUtils.html#formatLongOctalOrBinaryBytes(long,%20byte[],%20int,%20int)">formatLongOctalOrBinaryBytes</a></strong>(long&nbsp;value,
  152. byte[]&nbsp;buf,
  153. int&nbsp;offset,
  154. int&nbsp;length)</code>
  155. <div class="block">Write an long integer into a buffer as an octal string if this
  156. will fit, or as a binary number otherwise.</div>
  157. </td>
  158. </tr>
  159. <tr class="altColor">
  160. <td class="colFirst"><code>static int</code></td>
  161. <td class="colLast"><code><strong><a href="../../../../../../org/apache/commons/compress/archivers/tar/TarUtils.html#formatNameBytes(java.lang.String,%20byte[],%20int,%20int)">formatNameBytes</a></strong>(<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;name,
  162. byte[]&nbsp;buf,
  163. int&nbsp;offset,
  164. int&nbsp;length)</code>
  165. <div class="block">Copy a name into a buffer.</div>
  166. </td>
  167. </tr>
  168. <tr class="rowColor">
  169. <td class="colFirst"><code>static int</code></td>
  170. <td class="colLast"><code><strong><a href="../../../../../../org/apache/commons/compress/archivers/tar/TarUtils.html#formatNameBytes(java.lang.String,%20byte[],%20int,%20int,%20org.apache.commons.compress.archivers.zip.ZipEncoding)">formatNameBytes</a></strong>(<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;name,
  171. byte[]&nbsp;buf,
  172. int&nbsp;offset,
  173. int&nbsp;length,
  174. <a href="../../../../../../org/apache/commons/compress/archivers/zip/ZipEncoding.html" title="interface in org.apache.commons.compress.archivers.zip">ZipEncoding</a>&nbsp;encoding)</code>
  175. <div class="block">Copy a name into a buffer.</div>
  176. </td>
  177. </tr>
  178. <tr class="altColor">
  179. <td class="colFirst"><code>static int</code></td>
  180. <td class="colLast"><code><strong><a href="../../../../../../org/apache/commons/compress/archivers/tar/TarUtils.html#formatOctalBytes(long,%20byte[],%20int,%20int)">formatOctalBytes</a></strong>(long&nbsp;value,
  181. byte[]&nbsp;buf,
  182. int&nbsp;offset,
  183. int&nbsp;length)</code>
  184. <div class="block">Write an octal integer into a buffer.</div>
  185. </td>
  186. </tr>
  187. <tr class="rowColor">
  188. <td class="colFirst"><code>static void</code></td>
  189. <td class="colLast"><code><strong><a href="../../../../../../org/apache/commons/compress/archivers/tar/TarUtils.html#formatUnsignedOctalString(long,%20byte[],%20int,%20int)">formatUnsignedOctalString</a></strong>(long&nbsp;value,
  190. byte[]&nbsp;buffer,
  191. int&nbsp;offset,
  192. int&nbsp;length)</code>
  193. <div class="block">Fill buffer with unsigned octal number, padded with leading zeroes.</div>
  194. </td>
  195. </tr>
  196. <tr class="altColor">
  197. <td class="colFirst"><code>static boolean</code></td>
  198. <td class="colLast"><code><strong><a href="../../../../../../org/apache/commons/compress/archivers/tar/TarUtils.html#parseBoolean(byte[],%20int)">parseBoolean</a></strong>(byte[]&nbsp;buffer,
  199. int&nbsp;offset)</code>
  200. <div class="block">Parse a boolean byte from a buffer.</div>
  201. </td>
  202. </tr>
  203. <tr class="rowColor">
  204. <td class="colFirst"><code>static <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a></code></td>
  205. <td class="colLast"><code><strong><a href="../../../../../../org/apache/commons/compress/archivers/tar/TarUtils.html#parseName(byte[],%20int,%20int)">parseName</a></strong>(byte[]&nbsp;buffer,
  206. int&nbsp;offset,
  207. int&nbsp;length)</code>
  208. <div class="block">Parse an entry name from a buffer.</div>
  209. </td>
  210. </tr>
  211. <tr class="altColor">
  212. <td class="colFirst"><code>static <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a></code></td>
  213. <td class="colLast"><code><strong><a href="../../../../../../org/apache/commons/compress/archivers/tar/TarUtils.html#parseName(byte[],%20int,%20int,%20org.apache.commons.compress.archivers.zip.ZipEncoding)">parseName</a></strong>(byte[]&nbsp;buffer,
  214. int&nbsp;offset,
  215. int&nbsp;length,
  216. <a href="../../../../../../org/apache/commons/compress/archivers/zip/ZipEncoding.html" title="interface in org.apache.commons.compress.archivers.zip">ZipEncoding</a>&nbsp;encoding)</code>
  217. <div class="block">Parse an entry name from a buffer.</div>
  218. </td>
  219. </tr>
  220. <tr class="rowColor">
  221. <td class="colFirst"><code>static long</code></td>
  222. <td class="colLast"><code><strong><a href="../../../../../../org/apache/commons/compress/archivers/tar/TarUtils.html#parseOctal(byte[],%20int,%20int)">parseOctal</a></strong>(byte[]&nbsp;buffer,
  223. int&nbsp;offset,
  224. int&nbsp;length)</code>
  225. <div class="block">Parse an octal string from a buffer.</div>
  226. </td>
  227. </tr>
  228. <tr class="altColor">
  229. <td class="colFirst"><code>static long</code></td>
  230. <td class="colLast"><code><strong><a href="../../../../../../org/apache/commons/compress/archivers/tar/TarUtils.html#parseOctalOrBinary(byte[],%20int,%20int)">parseOctalOrBinary</a></strong>(byte[]&nbsp;buffer,
  231. int&nbsp;offset,
  232. int&nbsp;length)</code>
  233. <div class="block">Compute the value contained in a byte buffer.</div>
  234. </td>
  235. </tr>
  236. <tr class="rowColor">
  237. <td class="colFirst"><code>static boolean</code></td>
  238. <td class="colLast"><code><strong><a href="../../../../../../org/apache/commons/compress/archivers/tar/TarUtils.html#verifyCheckSum(byte[])">verifyCheckSum</a></strong>(byte[]&nbsp;header)</code>
  239. <div class="block">Wikipedia <a href="http://en.wikipedia.org/wiki/Tar_(file_format)#File_header">says</a>:
  240. The checksum is calculated by taking the sum of the unsigned byte values
  241. of the header block with the eight checksum bytes taken to be ascii
  242. spaces (decimal value 32).</div>
  243. </td>
  244. </tr>
  245. </table>
  246. <ul class="blockList">
  247. <li class="blockList"><a name="methods_inherited_from_class_java.lang.Object">
  248. <!-- -->
  249. </a>
  250. <h3>Methods inherited from class&nbsp;java.lang.<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a></h3>
  251. <code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#clone()" title="class or interface in java.lang">clone</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#equals(java.lang.Object)" title="class or interface in java.lang">equals</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#finalize()" title="class or interface in java.lang">finalize</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#getClass()" title="class or interface in java.lang">getClass</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#hashCode()" title="class or interface in java.lang">hashCode</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#notify()" title="class or interface in java.lang">notify</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#notifyAll()" title="class or interface in java.lang">notifyAll</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#toString()" title="class or interface in java.lang">toString</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#wait()" title="class or interface in java.lang">wait</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#wait(long)" title="class or interface in java.lang">wait</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#wait(long,%20int)" title="class or interface in java.lang">wait</a></code></li>
  252. </ul>
  253. </li>
  254. </ul>
  255. </li>
  256. </ul>
  257. </div>
  258. <div class="details">
  259. <ul class="blockList">
  260. <li class="blockList">
  261. <!-- ============ METHOD DETAIL ========== -->
  262. <ul class="blockList">
  263. <li class="blockList"><a name="method_detail">
  264. <!-- -->
  265. </a>
  266. <h3>Method Detail</h3>
  267. <a name="parseOctal(byte[], int, int)">
  268. <!-- -->
  269. </a>
  270. <ul class="blockList">
  271. <li class="blockList">
  272. <h4>parseOctal</h4>
  273. <pre>public static&nbsp;long&nbsp;<a href="../../../../../../src-html/org/apache/commons/compress/archivers/tar/TarUtils.html#line.104">parseOctal</a>(byte[]&nbsp;buffer,
  274. int&nbsp;offset,
  275. int&nbsp;length)</pre>
  276. <div class="block">Parse an octal string from a buffer.
  277. <p>Leading spaces are ignored.
  278. The buffer must contain a trailing space or NUL,
  279. and may contain an additional trailing space or NUL.</p>
  280. <p>The input buffer is allowed to contain all NULs,
  281. in which case the method returns 0L
  282. (this allows for missing fields).</p>
  283. <p>To work-around some tar implementations that insert a
  284. leading NUL this method returns 0 if it detects a leading NUL
  285. since Commons Compress 1.4.</p></div>
  286. <dl><dt><span class="strong">Parameters:</span></dt><dd><code>buffer</code> - The buffer from which to parse.</dd><dd><code>offset</code> - The offset into the buffer from which to parse.</dd><dd><code>length</code> - The maximum number of bytes to parse - must be at least 2 bytes.</dd>
  287. <dt><span class="strong">Returns:</span></dt><dd>The long value of the octal string.</dd>
  288. <dt><span class="strong">Throws:</span></dt>
  289. <dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</a></code> - if the trailing space/NUL is missing or if a invalid byte is detected.</dd></dl>
  290. </li>
  291. </ul>
  292. <a name="parseOctalOrBinary(byte[], int, int)">
  293. <!-- -->
  294. </a>
  295. <ul class="blockList">
  296. <li class="blockList">
  297. <h4>parseOctalOrBinary</h4>
  298. <pre>public static&nbsp;long&nbsp;<a href="../../../../../../src-html/org/apache/commons/compress/archivers/tar/TarUtils.html#line.167">parseOctalOrBinary</a>(byte[]&nbsp;buffer,
  299. int&nbsp;offset,
  300. int&nbsp;length)</pre>
  301. <div class="block">Compute the value contained in a byte buffer. If the most
  302. significant bit of the first byte in the buffer is set, this
  303. bit is ignored and the rest of the buffer is interpreted as a
  304. binary number. Otherwise, the buffer is interpreted as an
  305. octal number as per the parseOctal function above.</div>
  306. <dl><dt><span class="strong">Parameters:</span></dt><dd><code>buffer</code> - The buffer from which to parse.</dd><dd><code>offset</code> - The offset into the buffer from which to parse.</dd><dd><code>length</code> - The maximum number of bytes to parse.</dd>
  307. <dt><span class="strong">Returns:</span></dt><dd>The long value of the octal or binary string.</dd>
  308. <dt><span class="strong">Throws:</span></dt>
  309. <dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</a></code> - if the trailing space/NUL is
  310. missing or an invalid byte is detected in an octal number, or
  311. if a binary number would exceed the size of a signed long
  312. 64-bit integer.</dd><dt><span class="strong">Since:</span></dt>
  313. <dd>1.4</dd></dl>
  314. </li>
  315. </ul>
  316. <a name="parseBoolean(byte[], int)">
  317. <!-- -->
  318. </a>
  319. <ul class="blockList">
  320. <li class="blockList">
  321. <h4>parseBoolean</h4>
  322. <pre>public static&nbsp;boolean&nbsp;<a href="../../../../../../src-html/org/apache/commons/compress/archivers/tar/TarUtils.html#line.231">parseBoolean</a>(byte[]&nbsp;buffer,
  323. int&nbsp;offset)</pre>
  324. <div class="block">Parse a boolean byte from a buffer.
  325. Leading spaces and NUL are ignored.
  326. The buffer may contain trailing spaces or NULs.</div>
  327. <dl><dt><span class="strong">Parameters:</span></dt><dd><code>buffer</code> - The buffer from which to parse.</dd><dd><code>offset</code> - The offset into the buffer from which to parse.</dd>
  328. <dt><span class="strong">Returns:</span></dt><dd>The boolean value of the bytes.</dd>
  329. <dt><span class="strong">Throws:</span></dt>
  330. <dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</a></code> - if an invalid byte is detected.</dd></dl>
  331. </li>
  332. </ul>
  333. <a name="parseName(byte[], int, int)">
  334. <!-- -->
  335. </a>
  336. <ul class="blockList">
  337. <li class="blockList">
  338. <h4>parseName</h4>
  339. <pre>public static&nbsp;<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;<a href="../../../../../../src-html/org/apache/commons/compress/archivers/tar/TarUtils.html#line.262">parseName</a>(byte[]&nbsp;buffer,
  340. int&nbsp;offset,
  341. int&nbsp;length)</pre>
  342. <div class="block">Parse an entry name from a buffer.
  343. Parsing stops when a NUL is found
  344. or the buffer length is reached.</div>
  345. <dl><dt><span class="strong">Parameters:</span></dt><dd><code>buffer</code> - The buffer from which to parse.</dd><dd><code>offset</code> - The offset into the buffer from which to parse.</dd><dd><code>length</code> - The maximum number of bytes to parse.</dd>
  346. <dt><span class="strong">Returns:</span></dt><dd>The entry name.</dd></dl>
  347. </li>
  348. </ul>
  349. <a name="parseName(byte[], int, int, org.apache.commons.compress.archivers.zip.ZipEncoding)">
  350. <!-- -->
  351. </a>
  352. <ul class="blockList">
  353. <li class="blockList">
  354. <h4>parseName</h4>
  355. <pre>public static&nbsp;<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;<a href="../../../../../../src-html/org/apache/commons/compress/archivers/tar/TarUtils.html#line.288">parseName</a>(byte[]&nbsp;buffer,
  356. int&nbsp;offset,
  357. int&nbsp;length,
  358. <a href="../../../../../../org/apache/commons/compress/archivers/zip/ZipEncoding.html" title="interface in org.apache.commons.compress.archivers.zip">ZipEncoding</a>&nbsp;encoding)
  359. throws <a href="http://docs.oracle.com/javase/7/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</a></pre>
  360. <div class="block">Parse an entry name from a buffer.
  361. Parsing stops when a NUL is found
  362. or the buffer length is reached.</div>
  363. <dl><dt><span class="strong">Parameters:</span></dt><dd><code>buffer</code> - The buffer from which to parse.</dd><dd><code>offset</code> - The offset into the buffer from which to parse.</dd><dd><code>length</code> - The maximum number of bytes to parse.</dd><dd><code>encoding</code> - name of the encoding to use for file names</dd>
  364. <dt><span class="strong">Returns:</span></dt><dd>The entry name.</dd>
  365. <dt><span class="strong">Throws:</span></dt>
  366. <dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</a></code> - on error</dd><dt><span class="strong">Since:</span></dt>
  367. <dd>1.4</dd></dl>
  368. </li>
  369. </ul>
  370. <a name="formatNameBytes(java.lang.String, byte[], int, int)">
  371. <!-- -->
  372. </a>
  373. <ul class="blockList">
  374. <li class="blockList">
  375. <h4>formatNameBytes</h4>
  376. <pre>public static&nbsp;int&nbsp;<a href="../../../../../../src-html/org/apache/commons/compress/archivers/tar/TarUtils.html#line.322">formatNameBytes</a>(<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;name,
  377. byte[]&nbsp;buf,
  378. int&nbsp;offset,
  379. int&nbsp;length)</pre>
  380. <div class="block">Copy a name into a buffer.
  381. Copies characters from the name into the buffer
  382. starting at the specified offset.
  383. If the buffer is longer than the name, the buffer
  384. is filled with trailing NULs.
  385. If the name is longer than the buffer,
  386. the output is truncated.</div>
  387. <dl><dt><span class="strong">Parameters:</span></dt><dd><code>name</code> - The header name from which to copy the characters.</dd><dd><code>buf</code> - The buffer where the name is to be stored.</dd><dd><code>offset</code> - The starting offset into the buffer</dd><dd><code>length</code> - The maximum number of header bytes to copy.</dd>
  388. <dt><span class="strong">Returns:</span></dt><dd>The updated offset, i.e. offset + length</dd></dl>
  389. </li>
  390. </ul>
  391. <a name="formatNameBytes(java.lang.String, byte[], int, int, org.apache.commons.compress.archivers.zip.ZipEncoding)">
  392. <!-- -->
  393. </a>
  394. <ul class="blockList">
  395. <li class="blockList">
  396. <h4>formatNameBytes</h4>
  397. <pre>public static&nbsp;int&nbsp;<a href="../../../../../../src-html/org/apache/commons/compress/archivers/tar/TarUtils.html#line.354">formatNameBytes</a>(<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;name,
  398. byte[]&nbsp;buf,
  399. int&nbsp;offset,
  400. int&nbsp;length,
  401. <a href="../../../../../../org/apache/commons/compress/archivers/zip/ZipEncoding.html" title="interface in org.apache.commons.compress.archivers.zip">ZipEncoding</a>&nbsp;encoding)
  402. throws <a href="http://docs.oracle.com/javase/7/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</a></pre>
  403. <div class="block">Copy a name into a buffer.
  404. Copies characters from the name into the buffer
  405. starting at the specified offset.
  406. If the buffer is longer than the name, the buffer
  407. is filled with trailing NULs.
  408. If the name is longer than the buffer,
  409. the output is truncated.</div>
  410. <dl><dt><span class="strong">Parameters:</span></dt><dd><code>name</code> - The header name from which to copy the characters.</dd><dd><code>buf</code> - The buffer where the name is to be stored.</dd><dd><code>offset</code> - The starting offset into the buffer</dd><dd><code>length</code> - The maximum number of header bytes to copy.</dd><dd><code>encoding</code> - name of the encoding to use for file names</dd>
  411. <dt><span class="strong">Returns:</span></dt><dd>The updated offset, i.e. offset + length</dd>
  412. <dt><span class="strong">Throws:</span></dt>
  413. <dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</a></code> - on error</dd><dt><span class="strong">Since:</span></dt>
  414. <dd>1.4</dd></dl>
  415. </li>
  416. </ul>
  417. <a name="formatUnsignedOctalString(long, byte[], int, int)">
  418. <!-- -->
  419. </a>
  420. <ul class="blockList">
  421. <li class="blockList">
  422. <h4>formatUnsignedOctalString</h4>
  423. <pre>public static&nbsp;void&nbsp;<a href="../../../../../../src-html/org/apache/commons/compress/archivers/tar/TarUtils.html#line.383">formatUnsignedOctalString</a>(long&nbsp;value,
  424. byte[]&nbsp;buffer,
  425. int&nbsp;offset,
  426. int&nbsp;length)</pre>
  427. <div class="block">Fill buffer with unsigned octal number, padded with leading zeroes.</div>
  428. <dl><dt><span class="strong">Parameters:</span></dt><dd><code>value</code> - number to convert to octal - treated as unsigned</dd><dd><code>buffer</code> - destination buffer</dd><dd><code>offset</code> - starting offset in buffer</dd><dd><code>length</code> - length of buffer to fill</dd>
  429. <dt><span class="strong">Throws:</span></dt>
  430. <dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</a></code> - if the value will not fit in the buffer</dd></dl>
  431. </li>
  432. </ul>
  433. <a name="formatOctalBytes(long, byte[], int, int)">
  434. <!-- -->
  435. </a>
  436. <ul class="blockList">
  437. <li class="blockList">
  438. <h4>formatOctalBytes</h4>
  439. <pre>public static&nbsp;int&nbsp;<a href="../../../../../../src-html/org/apache/commons/compress/archivers/tar/TarUtils.html#line.422">formatOctalBytes</a>(long&nbsp;value,
  440. byte[]&nbsp;buf,
  441. int&nbsp;offset,
  442. int&nbsp;length)</pre>
  443. <div class="block">Write an octal integer into a buffer.
  444. Uses <a href="../../../../../../org/apache/commons/compress/archivers/tar/TarUtils.html#formatUnsignedOctalString(long,%20byte[],%20int,%20int)"><code>formatUnsignedOctalString(long, byte[], int, int)</code></a> to format
  445. the value as an octal string with leading zeros.
  446. The converted number is followed by space and NUL</div>
  447. <dl><dt><span class="strong">Parameters:</span></dt><dd><code>value</code> - The value to write</dd><dd><code>buf</code> - The buffer to receive the output</dd><dd><code>offset</code> - The starting offset into the buffer</dd><dd><code>length</code> - The size of the output buffer</dd>
  448. <dt><span class="strong">Returns:</span></dt><dd>The updated offset, i.e offset+length</dd>
  449. <dt><span class="strong">Throws:</span></dt>
  450. <dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</a></code> - if the value (and trailer) will not fit in the buffer</dd></dl>
  451. </li>
  452. </ul>
  453. <a name="formatLongOctalBytes(long, byte[], int, int)">
  454. <!-- -->
  455. </a>
  456. <ul class="blockList">
  457. <li class="blockList">
  458. <h4>formatLongOctalBytes</h4>
  459. <pre>public static&nbsp;int&nbsp;<a href="../../../../../../src-html/org/apache/commons/compress/archivers/tar/TarUtils.html#line.447">formatLongOctalBytes</a>(long&nbsp;value,
  460. byte[]&nbsp;buf,
  461. int&nbsp;offset,
  462. int&nbsp;length)</pre>
  463. <div class="block">Write an octal long integer into a buffer.
  464. Uses <a href="../../../../../../org/apache/commons/compress/archivers/tar/TarUtils.html#formatUnsignedOctalString(long,%20byte[],%20int,%20int)"><code>formatUnsignedOctalString(long, byte[], int, int)</code></a> to format
  465. the value as an octal string with leading zeros.
  466. The converted number is followed by a space.</div>
  467. <dl><dt><span class="strong">Parameters:</span></dt><dd><code>value</code> - The value to write as octal</dd><dd><code>buf</code> - The destinationbuffer.</dd><dd><code>offset</code> - The starting offset into the buffer.</dd><dd><code>length</code> - The length of the buffer</dd>
  468. <dt><span class="strong">Returns:</span></dt><dd>The updated offset</dd>
  469. <dt><span class="strong">Throws:</span></dt>
  470. <dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</a></code> - if the value (and trailer) will not fit in the buffer</dd></dl>
  471. </li>
  472. </ul>
  473. <a name="formatLongOctalOrBinaryBytes(long, byte[], int, int)">
  474. <!-- -->
  475. </a>
  476. <ul class="blockList">
  477. <li class="blockList">
  478. <h4>formatLongOctalOrBinaryBytes</h4>
  479. <pre>public static&nbsp;int&nbsp;<a href="../../../../../../src-html/org/apache/commons/compress/archivers/tar/TarUtils.html#line.474">formatLongOctalOrBinaryBytes</a>(long&nbsp;value,
  480. byte[]&nbsp;buf,
  481. int&nbsp;offset,
  482. int&nbsp;length)</pre>
  483. <div class="block">Write an long integer into a buffer as an octal string if this
  484. will fit, or as a binary number otherwise.
  485. Uses <a href="../../../../../../org/apache/commons/compress/archivers/tar/TarUtils.html#formatUnsignedOctalString(long,%20byte[],%20int,%20int)"><code>formatUnsignedOctalString(long, byte[], int, int)</code></a> to format
  486. the value as an octal string with leading zeros.
  487. The converted number is followed by a space.</div>
  488. <dl><dt><span class="strong">Parameters:</span></dt><dd><code>value</code> - The value to write into the buffer.</dd><dd><code>buf</code> - The destination buffer.</dd><dd><code>offset</code> - The starting offset into the buffer.</dd><dd><code>length</code> - The length of the buffer.</dd>
  489. <dt><span class="strong">Returns:</span></dt><dd>The updated offset.</dd>
  490. <dt><span class="strong">Throws:</span></dt>
  491. <dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</a></code> - if the value (and trailer)
  492. will not fit in the buffer.</dd><dt><span class="strong">Since:</span></dt>
  493. <dd>1.4</dd></dl>
  494. </li>
  495. </ul>
  496. <a name="formatCheckSumOctalBytes(long, byte[], int, int)">
  497. <!-- -->
  498. </a>
  499. <ul class="blockList">
  500. <li class="blockList">
  501. <h4>formatCheckSumOctalBytes</h4>
  502. <pre>public static&nbsp;int&nbsp;<a href="../../../../../../src-html/org/apache/commons/compress/archivers/tar/TarUtils.html#line.544">formatCheckSumOctalBytes</a>(long&nbsp;value,
  503. byte[]&nbsp;buf,
  504. int&nbsp;offset,
  505. int&nbsp;length)</pre>
  506. <div class="block">Writes an octal value into a buffer.
  507. Uses <a href="../../../../../../org/apache/commons/compress/archivers/tar/TarUtils.html#formatUnsignedOctalString(long,%20byte[],%20int,%20int)"><code>formatUnsignedOctalString(long, byte[], int, int)</code></a> to format
  508. the value as an octal string with leading zeros.
  509. The converted number is followed by NUL and then space.</div>
  510. <dl><dt><span class="strong">Parameters:</span></dt><dd><code>value</code> - The value to convert</dd><dd><code>buf</code> - The destination buffer</dd><dd><code>offset</code> - The starting offset into the buffer.</dd><dd><code>length</code> - The size of the buffer.</dd>
  511. <dt><span class="strong">Returns:</span></dt><dd>The updated value of offset, i.e. offset+length</dd>
  512. <dt><span class="strong">Throws:</span></dt>
  513. <dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</a></code> - if the value (and trailer) will not fit in the buffer</dd></dl>
  514. </li>
  515. </ul>
  516. <a name="computeCheckSum(byte[])">
  517. <!-- -->
  518. </a>
  519. <ul class="blockList">
  520. <li class="blockList">
  521. <h4>computeCheckSum</h4>
  522. <pre>public static&nbsp;long&nbsp;<a href="../../../../../../src-html/org/apache/commons/compress/archivers/tar/TarUtils.html#line.561">computeCheckSum</a>(byte[]&nbsp;buf)</pre>
  523. <div class="block">Compute the checksum of a tar entry header.</div>
  524. <dl><dt><span class="strong">Parameters:</span></dt><dd><code>buf</code> - The tar entry's header buffer.</dd>
  525. <dt><span class="strong">Returns:</span></dt><dd>The computed checksum.</dd></dl>
  526. </li>
  527. </ul>
  528. <a name="verifyCheckSum(byte[])">
  529. <!-- -->
  530. </a>
  531. <ul class="blockListLast">
  532. <li class="blockList">
  533. <h4>verifyCheckSum</h4>
  534. <pre>public static&nbsp;boolean&nbsp;<a href="../../../../../../src-html/org/apache/commons/compress/archivers/tar/TarUtils.html#line.596">verifyCheckSum</a>(byte[]&nbsp;header)</pre>
  535. <div class="block">Wikipedia <a href="http://en.wikipedia.org/wiki/Tar_(file_format)#File_header">says</a>:
  536. <blockquote>
  537. The checksum is calculated by taking the sum of the unsigned byte values
  538. of the header block with the eight checksum bytes taken to be ascii
  539. spaces (decimal value 32). It is stored as a six digit octal number with
  540. leading zeroes followed by a NUL and then a space. Various
  541. implementations do not adhere to this format. For better compatibility,
  542. ignore leading and trailing whitespace, and get the first six digits. In
  543. addition, some historic tar implementations treated bytes as signed.
  544. Implementations typically calculate the checksum both ways, and treat it
  545. as good if either the signed or unsigned sum matches the included
  546. checksum.
  547. </blockquote>
  548. <p>
  549. The return value of this method should be treated as a best-effort
  550. heuristic rather than an absolute and final truth. The checksum
  551. verification logic may well evolve over time as more special cases
  552. are encountered.</div>
  553. <dl><dt><span class="strong">Parameters:</span></dt><dd><code>header</code> - tar header</dd>
  554. <dt><span class="strong">Returns:</span></dt><dd>whether the checksum is reasonably good</dd><dt><span class="strong">Since:</span></dt>
  555. <dd>1.5</dd>
  556. <dt><span class="strong">See Also:</span></dt><dd><a href="https://issues.apache.org/jira/browse/COMPRESS-191">COMPRESS-191</a></dd></dl>
  557. </li>
  558. </ul>
  559. </li>
  560. </ul>
  561. </li>
  562. </ul>
  563. </div>
  564. </div>
  565. <!-- ========= END OF CLASS DATA ========= -->
  566. <!-- ======= START OF BOTTOM NAVBAR ====== -->
  567. <div class="bottomNav"><a name="navbar_bottom">
  568. <!-- -->
  569. </a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="navbar_bottom_firstrow">
  570. <!-- -->
  571. </a>
  572. <ul class="navList" title="Navigation">
  573. <li><a href="../../../../../../overview-summary.html">Overview</a></li>
  574. <li><a href="package-summary.html">Package</a></li>
  575. <li class="navBarCell1Rev">Class</li>
  576. <li><a href="class-use/TarUtils.html">Use</a></li>
  577. <li><a href="package-tree.html">Tree</a></li>
  578. <li><a href="../../../../../../deprecated-list.html">Deprecated</a></li>
  579. <li><a href="../../../../../../index-all.html">Index</a></li>
  580. <li><a href="../../../../../../help-doc.html">Help</a></li>
  581. </ul>
  582. </div>
  583. <div class="subNav">
  584. <ul class="navList">
  585. <li><a href="../../../../../../org/apache/commons/compress/archivers/tar/TarConstants.html" title="interface in org.apache.commons.compress.archivers.tar"><span class="strong">Prev Class</span></a></li>
  586. <li>Next Class</li>
  587. </ul>
  588. <ul class="navList">
  589. <li><a href="../../../../../../index.html?org/apache/commons/compress/archivers/tar/TarUtils.html" target="_top">Frames</a></li>
  590. <li><a href="TarUtils.html" target="_top">No Frames</a></li>
  591. </ul>
  592. <ul class="navList" id="allclasses_navbar_bottom">
  593. <li><a href="../../../../../../allclasses-noframe.html">All Classes</a></li>
  594. </ul>
  595. <div>
  596. <script type="text/javascript"><!--
  597. allClassesLink = document.getElementById("allclasses_navbar_bottom");
  598. if(window==top) {
  599. allClassesLink.style.display = "block";
  600. }
  601. else {
  602. allClassesLink.style.display = "none";
  603. }
  604. //-->
  605. </script>
  606. </div>
  607. <div>
  608. <ul class="subNavList">
  609. <li>Summary:&nbsp;</li>
  610. <li>Nested&nbsp;|&nbsp;</li>
  611. <li>Field&nbsp;|&nbsp;</li>
  612. <li>Constr&nbsp;|&nbsp;</li>
  613. <li><a href="#method_summary">Method</a></li>
  614. </ul>
  615. <ul class="subNavList">
  616. <li>Detail:&nbsp;</li>
  617. <li>Field&nbsp;|&nbsp;</li>
  618. <li>Constr&nbsp;|&nbsp;</li>
  619. <li><a href="#method_detail">Method</a></li>
  620. </ul>
  621. </div>
  622. <a name="skip-navbar_bottom">
  623. <!-- -->
  624. </a></div>
  625. <!-- ======== END OF BOTTOM NAVBAR ======= -->
  626. <p class="legalCopy"><small>Copyright &#169; 2016 <a href="https://www.apache.org/">The Apache Software Foundation</a>. All rights reserved.</small></p>
  627. </body>
  628. </html>