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.

ZipEntry.java 23 kB

11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719
  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. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. *
  17. */
  18. package org.apache.tools.zip;
  19. import java.io.File;
  20. import java.util.ArrayList;
  21. import java.util.Arrays;
  22. import java.util.Date;
  23. import java.util.LinkedHashMap;
  24. import java.util.List;
  25. import java.util.zip.ZipException;
  26. /**
  27. * Extension that adds better handling of extra fields and provides
  28. * access to the internal and external file attributes.
  29. *
  30. * <p>The extra data is expected to follow the recommendation of
  31. * {@link <a href="http://www.pkware.com/documents/casestudies/APPNOTE.TXT">
  32. * APPNOTE.txt</a>}:</p>
  33. * <ul>
  34. * <li>the extra byte array consists of a sequence of extra fields</li>
  35. * <li>each extra fields starts by a two byte header id followed by
  36. * a two byte sequence holding the length of the remainder of
  37. * data.</li>
  38. * </ul>
  39. *
  40. * <p>Any extra data that cannot be parsed by the rules above will be
  41. * consumed as "unparseable" extra data and treated differently by the
  42. * methods of this class. Older versions would have thrown an
  43. * exception if any attempt was made to read or write extra data not
  44. * conforming to the recommendation.</p>
  45. *
  46. */
  47. public class ZipEntry extends java.util.zip.ZipEntry implements Cloneable {
  48. public static final int PLATFORM_UNIX = 3;
  49. public static final int PLATFORM_FAT = 0;
  50. private static final int SHORT_MASK = 0xFFFF;
  51. private static final int SHORT_SHIFT = 16;
  52. private static final byte[] EMPTY = new byte[0];
  53. /**
  54. * The {@link java.util.zip.ZipEntry} base class only supports
  55. * the compression methods STORED and DEFLATED. We override the
  56. * field so that any compression methods can be used.
  57. * <p>
  58. * The default value -1 means that the method has not been specified.
  59. */
  60. private int method = -1;
  61. /**
  62. * The {@link java.util.zip.ZipEntry#setSize} method in the base
  63. * class throws an IllegalArgumentException if the size is bigger
  64. * than 2GB for Java versions < 7. Need to keep our own size
  65. * information for Zip64 support.
  66. */
  67. private long size = -1;
  68. private int internalAttributes = 0;
  69. private int platform = PLATFORM_FAT;
  70. private long externalAttributes = 0;
  71. private LinkedHashMap<ZipShort, ZipExtraField> extraFields = null;
  72. private UnparseableExtraFieldData unparseableExtra = null;
  73. private String name = null;
  74. private byte[] rawName = null;
  75. private GeneralPurposeBit gpb = new GeneralPurposeBit();
  76. /**
  77. * Creates a new zip entry with the specified name.
  78. *
  79. * <p>Assumes the entry represents a directory if and only if the
  80. * name ends with a forward slash "/".</p>
  81. *
  82. * @param name the name of the entry
  83. * @since 1.1
  84. */
  85. public ZipEntry(final String name) {
  86. super(name);
  87. setName(name);
  88. }
  89. /**
  90. * Creates a new zip entry with fields taken from the specified zip entry.
  91. *
  92. * <p>Assumes the entry represents a directory if and only if the
  93. * name ends with a forward slash "/".</p>
  94. *
  95. * @param entry the entry to get fields from
  96. * @since 1.1
  97. * @throws ZipException on error
  98. */
  99. public ZipEntry(final java.util.zip.ZipEntry entry) throws ZipException {
  100. super(entry);
  101. setName(entry.getName());
  102. final byte[] extra = entry.getExtra();
  103. if (extra != null) {
  104. setExtraFields(ExtraFieldUtils.parse(extra, true,
  105. ExtraFieldUtils
  106. .UnparseableExtraField.READ));
  107. } else {
  108. // initializes extra data to an empty byte array
  109. setExtra();
  110. }
  111. setMethod(entry.getMethod());
  112. this.size = entry.getSize();
  113. }
  114. /**
  115. * Creates a new zip entry with fields taken from the specified zip entry.
  116. *
  117. * <p>Assumes the entry represents a directory if and only if the
  118. * name ends with a forward slash "/".</p>
  119. *
  120. * @param entry the entry to get fields from
  121. * @throws ZipException on error
  122. * @since 1.1
  123. */
  124. public ZipEntry(final ZipEntry entry) throws ZipException {
  125. this((java.util.zip.ZipEntry) entry);
  126. setInternalAttributes(entry.getInternalAttributes());
  127. setExternalAttributes(entry.getExternalAttributes());
  128. setExtraFields(entry.getExtraFields(true));
  129. setPlatform(entry.getPlatform());
  130. GeneralPurposeBit other = entry.getGeneralPurposeBit();
  131. setGeneralPurposeBit(other == null ? null :
  132. (GeneralPurposeBit) other.clone());
  133. }
  134. /**
  135. * @since 1.9
  136. */
  137. protected ZipEntry() {
  138. this("");
  139. }
  140. /**
  141. * Creates a new zip entry taking some information from the given
  142. * file and using the provided name.
  143. *
  144. * <p>The name will be adjusted to end with a forward slash "/" if
  145. * the file is a directory. If the file is not a directory a
  146. * potential trailing forward slash will be stripped from the
  147. * entry name.</p>
  148. */
  149. public ZipEntry(final File inputFile, final String entryName) {
  150. this(inputFile.isDirectory() && !entryName.endsWith("/") ?
  151. entryName + "/" : entryName);
  152. if (inputFile.isFile()){
  153. setSize(inputFile.length());
  154. }
  155. setTime(inputFile.lastModified());
  156. // TODO are there any other fields we can set here?
  157. }
  158. /**
  159. * Overwrite clone.
  160. * @return a cloned copy of this ZipEntry
  161. * @since 1.1
  162. */
  163. @Override
  164. public Object clone() {
  165. final ZipEntry e = (ZipEntry) super.clone();
  166. e.setInternalAttributes(getInternalAttributes());
  167. e.setExternalAttributes(getExternalAttributes());
  168. e.setExtraFields(getExtraFields(true));
  169. return e;
  170. }
  171. /**
  172. * Returns the compression method of this entry, or -1 if the
  173. * compression method has not been specified.
  174. *
  175. * @return compression method
  176. */
  177. @Override
  178. public int getMethod() {
  179. return method;
  180. }
  181. /**
  182. * Sets the compression method of this entry.
  183. *
  184. * @param method compression method
  185. */
  186. @Override
  187. public void setMethod(final int method) {
  188. if (method < 0) {
  189. throw new IllegalArgumentException(
  190. "ZIP compression method can not be negative: " + method);
  191. }
  192. this.method = method;
  193. }
  194. /**
  195. * Retrieves the internal file attributes.
  196. *
  197. * @return the internal file attributes
  198. * @since 1.1
  199. */
  200. public int getInternalAttributes() {
  201. return internalAttributes;
  202. }
  203. /**
  204. * Sets the internal file attributes.
  205. * @param value an <code>int</code> value
  206. * @since 1.1
  207. */
  208. public void setInternalAttributes(final int value) {
  209. internalAttributes = value;
  210. }
  211. /**
  212. * Retrieves the external file attributes.
  213. * @return the external file attributes
  214. * @since 1.1
  215. */
  216. public long getExternalAttributes() {
  217. return externalAttributes;
  218. }
  219. /**
  220. * Sets the external file attributes.
  221. * @param value an <code>long</code> value
  222. * @since 1.1
  223. */
  224. public void setExternalAttributes(final long value) {
  225. externalAttributes = value;
  226. }
  227. /**
  228. * Sets Unix permissions in a way that is understood by Info-Zip's
  229. * unzip command.
  230. * @param mode an <code>int</code> value
  231. * @since Ant 1.5.2
  232. */
  233. public void setUnixMode(final int mode) {
  234. // CheckStyle:MagicNumberCheck OFF - no point
  235. setExternalAttributes((mode << SHORT_SHIFT)
  236. // MS-DOS read-only attribute
  237. | ((mode & 0200) == 0 ? 1 : 0)
  238. // MS-DOS directory flag
  239. | (isDirectory() ? 0x10 : 0));
  240. // CheckStyle:MagicNumberCheck ON
  241. platform = PLATFORM_UNIX;
  242. }
  243. /**
  244. * Unix permission.
  245. * @return the unix permissions
  246. * @since Ant 1.6
  247. */
  248. public int getUnixMode() {
  249. return platform != PLATFORM_UNIX ? 0 :
  250. (int) ((getExternalAttributes() >> SHORT_SHIFT) & SHORT_MASK);
  251. }
  252. /**
  253. * Platform specification to put into the &quot;version made
  254. * by&quot; part of the central file header.
  255. *
  256. * @return PLATFORM_FAT unless {@link #setUnixMode setUnixMode}
  257. * has been called, in which case PLATFORM_UNIX will be returned.
  258. *
  259. * @since Ant 1.5.2
  260. */
  261. public int getPlatform() {
  262. return platform;
  263. }
  264. /**
  265. * Set the platform (UNIX or FAT).
  266. * @param platform an <code>int</code> value - 0 is FAT, 3 is UNIX
  267. * @since 1.9
  268. */
  269. protected void setPlatform(final int platform) {
  270. this.platform = platform;
  271. }
  272. /**
  273. * Replaces all currently attached extra fields with the new array.
  274. * @param fields an array of extra fields
  275. * @since 1.1
  276. */
  277. public void setExtraFields(final ZipExtraField[] fields) {
  278. extraFields = new LinkedHashMap<ZipShort, ZipExtraField>();
  279. for (final ZipExtraField field : fields) {
  280. if (field instanceof UnparseableExtraFieldData) {
  281. unparseableExtra = (UnparseableExtraFieldData) field;
  282. } else {
  283. extraFields.put(field.getHeaderId(), field);
  284. }
  285. }
  286. setExtra();
  287. }
  288. /**
  289. * Retrieves all extra fields that have been parsed successfully.
  290. * @return an array of the extra fields
  291. */
  292. public ZipExtraField[] getExtraFields() {
  293. return getExtraFields(false);
  294. }
  295. /**
  296. * Retrieves extra fields.
  297. * @param includeUnparseable whether to also return unparseable
  298. * extra fields as {@link UnparseableExtraFieldData} if such data
  299. * exists.
  300. * @return an array of the extra fields
  301. * @since 1.1
  302. */
  303. public ZipExtraField[] getExtraFields(final boolean includeUnparseable) {
  304. if (extraFields == null) {
  305. return !includeUnparseable || unparseableExtra == null
  306. ? new ZipExtraField[0]
  307. : new ZipExtraField[] {unparseableExtra};
  308. }
  309. final List<ZipExtraField> result =
  310. new ArrayList<ZipExtraField>(extraFields.values());
  311. if (includeUnparseable && unparseableExtra != null) {
  312. result.add(unparseableExtra);
  313. }
  314. return result.toArray(new ZipExtraField[0]);
  315. }
  316. /**
  317. * Adds an extra field - replacing an already present extra field
  318. * of the same type.
  319. *
  320. * <p>If no extra field of the same type exists, the field will be
  321. * added as last field.</p>
  322. * @param ze an extra field
  323. * @since 1.1
  324. */
  325. public void addExtraField(final ZipExtraField ze) {
  326. if (ze instanceof UnparseableExtraFieldData) {
  327. unparseableExtra = (UnparseableExtraFieldData) ze;
  328. } else {
  329. if (extraFields == null) {
  330. extraFields = new LinkedHashMap<ZipShort, ZipExtraField>();
  331. }
  332. extraFields.put(ze.getHeaderId(), ze);
  333. }
  334. setExtra();
  335. }
  336. /**
  337. * Adds an extra field - replacing an already present extra field
  338. * of the same type.
  339. *
  340. * <p>The new extra field will be the first one.</p>
  341. * @param ze an extra field
  342. * @since 1.1
  343. */
  344. public void addAsFirstExtraField(final ZipExtraField ze) {
  345. if (ze instanceof UnparseableExtraFieldData) {
  346. unparseableExtra = (UnparseableExtraFieldData) ze;
  347. } else {
  348. final LinkedHashMap<ZipShort, ZipExtraField> copy = extraFields;
  349. extraFields = new LinkedHashMap<ZipShort, ZipExtraField>();
  350. extraFields.put(ze.getHeaderId(), ze);
  351. if (copy != null) {
  352. copy.remove(ze.getHeaderId());
  353. extraFields.putAll(copy);
  354. }
  355. }
  356. setExtra();
  357. }
  358. /**
  359. * Remove an extra field.
  360. * @param type the type of extra field to remove
  361. * @since 1.1
  362. */
  363. public void removeExtraField(final ZipShort type) {
  364. if (extraFields == null) {
  365. throw new java.util.NoSuchElementException();
  366. }
  367. if (extraFields.remove(type) == null) {
  368. throw new java.util.NoSuchElementException();
  369. }
  370. setExtra();
  371. }
  372. /**
  373. * Removes unparseable extra field data.
  374. */
  375. public void removeUnparseableExtraFieldData() {
  376. if (unparseableExtra == null) {
  377. throw new java.util.NoSuchElementException();
  378. }
  379. unparseableExtra = null;
  380. setExtra();
  381. }
  382. /**
  383. * Looks up an extra field by its header id.
  384. *
  385. * @return null if no such field exists.
  386. */
  387. public ZipExtraField getExtraField(final ZipShort type) {
  388. if (extraFields != null) {
  389. return extraFields.get(type);
  390. }
  391. return null;
  392. }
  393. /**
  394. * Looks up extra field data that couldn't be parsed correctly.
  395. *
  396. * @return null if no such field exists.
  397. */
  398. public UnparseableExtraFieldData getUnparseableExtraFieldData() {
  399. return unparseableExtra;
  400. }
  401. /**
  402. * Parses the given bytes as extra field data and consumes any
  403. * unparseable data as an {@link UnparseableExtraFieldData}
  404. * instance.
  405. * @param extra an array of bytes to be parsed into extra fields
  406. * @throws RuntimeException if the bytes cannot be parsed
  407. * @since 1.1
  408. * @throws RuntimeException on error
  409. */
  410. @Override
  411. public void setExtra(final byte[] extra) throws RuntimeException {
  412. try {
  413. final ZipExtraField[] local =
  414. ExtraFieldUtils.parse(extra, true,
  415. ExtraFieldUtils.UnparseableExtraField.READ);
  416. mergeExtraFields(local, true);
  417. } catch (final ZipException e) {
  418. // actually this is not be possible as of Ant 1.8.1
  419. throw new RuntimeException("Error parsing extra fields for entry: "
  420. + getName() + " - " + e.getMessage(), e);
  421. }
  422. }
  423. /**
  424. * Unfortunately {@link java.util.zip.ZipOutputStream
  425. * java.util.zip.ZipOutputStream} seems to access the extra data
  426. * directly, so overriding getExtra doesn't help - we need to
  427. * modify super's data directly.
  428. *
  429. * @since 1.1
  430. */
  431. protected void setExtra() {
  432. super.setExtra(ExtraFieldUtils.mergeLocalFileDataData(getExtraFields(true)));
  433. }
  434. /**
  435. * Sets the central directory part of extra fields.
  436. */
  437. public void setCentralDirectoryExtra(final byte[] b) {
  438. try {
  439. final ZipExtraField[] central =
  440. ExtraFieldUtils.parse(b, false,
  441. ExtraFieldUtils.UnparseableExtraField.READ);
  442. mergeExtraFields(central, false);
  443. } catch (final ZipException e) {
  444. throw new RuntimeException(e.getMessage(), e);
  445. }
  446. }
  447. /**
  448. * Retrieves the extra data for the local file data.
  449. * @return the extra data for local file
  450. * @since 1.1
  451. */
  452. public byte[] getLocalFileDataExtra() {
  453. final byte[] extra = getExtra();
  454. return extra != null ? extra : EMPTY;
  455. }
  456. /**
  457. * Retrieves the extra data for the central directory.
  458. * @return the central directory extra data
  459. * @since 1.1
  460. */
  461. public byte[] getCentralDirectoryExtra() {
  462. return ExtraFieldUtils.mergeCentralDirectoryData(getExtraFields(true));
  463. }
  464. /**
  465. * Make this class work in JDK 1.1 like a 1.2 class.
  466. *
  467. * <p>This either stores the size for later usage or invokes
  468. * setCompressedSize via reflection.</p>
  469. * @param size the size to use
  470. * @deprecated since 1.7.
  471. * Use setCompressedSize directly.
  472. * @since 1.2
  473. */
  474. @Deprecated
  475. public void setComprSize(final long size) {
  476. setCompressedSize(size);
  477. }
  478. /**
  479. * Get the name of the entry.
  480. * @return the entry name
  481. * @since 1.9
  482. */
  483. @Override
  484. public String getName() {
  485. return name == null ? super.getName() : name;
  486. }
  487. /**
  488. * Is this entry a directory?
  489. * @return true if the entry is a directory
  490. * @since 1.10
  491. */
  492. @Override
  493. public boolean isDirectory() {
  494. return getName().endsWith("/");
  495. }
  496. /**
  497. * Set the name of the entry.
  498. * @param name the name to use
  499. */
  500. protected void setName(String name) {
  501. if (name != null && getPlatform() == PLATFORM_FAT
  502. && name.indexOf("/") == -1) {
  503. name = name.replace('\\', '/');
  504. }
  505. this.name = name;
  506. }
  507. /**
  508. * Gets the uncompressed size of the entry data.
  509. * @return the entry size
  510. */
  511. @Override
  512. public long getSize() {
  513. return size;
  514. }
  515. /**
  516. * Sets the uncompressed size of the entry data.
  517. * @param size the uncompressed size in bytes
  518. * @exception IllegalArgumentException if the specified size is less
  519. * than 0
  520. */
  521. @Override
  522. public void setSize(final long size) {
  523. if (size < 0) {
  524. throw new IllegalArgumentException("invalid entry size");
  525. }
  526. this.size = size;
  527. }
  528. /**
  529. * Sets the name using the raw bytes and the string created from
  530. * it by guessing or using the configured encoding.
  531. * @param name the name to use created from the raw bytes using
  532. * the guessed or configured encoding
  533. * @param rawName the bytes originally read as name from the
  534. * archive
  535. */
  536. protected void setName(final String name, final byte[] rawName) {
  537. setName(name);
  538. this.rawName = rawName;
  539. }
  540. /**
  541. * Returns the raw bytes that made up the name before it has been
  542. * converted using the configured or guessed encoding.
  543. *
  544. * <p>This method will return null if this instance has not been
  545. * read from an archive.</p>
  546. */
  547. public byte[] getRawName() {
  548. if (rawName != null) {
  549. final byte[] b = new byte[rawName.length];
  550. System.arraycopy(rawName, 0, b, 0, rawName.length);
  551. return b;
  552. }
  553. return null;
  554. }
  555. /**
  556. * Get the hashCode of the entry.
  557. * This uses the name as the hashcode.
  558. * @return a hashcode.
  559. * @since Ant 1.7
  560. */
  561. @Override
  562. public int hashCode() {
  563. // this method has severe consequences on performance. We cannot rely
  564. // on the super.hashCode() method since super.getName() always return
  565. // the empty string in the current implemention (there's no setter)
  566. // so it is basically draining the performance of a hashmap lookup
  567. return getName().hashCode();
  568. }
  569. /**
  570. * The "general purpose bit" field.
  571. */
  572. public GeneralPurposeBit getGeneralPurposeBit() {
  573. return gpb;
  574. }
  575. /**
  576. * The "general purpose bit" field.
  577. */
  578. public void setGeneralPurposeBit(final GeneralPurposeBit b) {
  579. gpb = b;
  580. }
  581. /**
  582. * If there are no extra fields, use the given fields as new extra
  583. * data - otherwise merge the fields assuming the existing fields
  584. * and the new fields stem from different locations inside the
  585. * archive.
  586. * @param f the extra fields to merge
  587. * @param local whether the new fields originate from local data
  588. */
  589. private void mergeExtraFields(final ZipExtraField[] f, final boolean local)
  590. throws ZipException {
  591. if (extraFields == null) {
  592. setExtraFields(f);
  593. } else {
  594. for (final ZipExtraField element : f) {
  595. ZipExtraField existing;
  596. if (element instanceof UnparseableExtraFieldData) {
  597. existing = unparseableExtra;
  598. } else {
  599. existing = getExtraField(element.getHeaderId());
  600. }
  601. if (existing == null) {
  602. addExtraField(element);
  603. } else {
  604. if (local
  605. || !(existing
  606. instanceof CentralDirectoryParsingZipExtraField)) {
  607. final byte[] b = element.getLocalFileDataData();
  608. existing.parseFromLocalFileData(b, 0, b.length);
  609. } else {
  610. final byte[] b = element.getCentralDirectoryData();
  611. ((CentralDirectoryParsingZipExtraField) existing)
  612. .parseFromCentralDirectoryData(b, 0, b.length);
  613. }
  614. }
  615. }
  616. setExtra();
  617. }
  618. }
  619. /** {@inheritDoc} */
  620. public Date getLastModifiedDate() {
  621. return new Date(getTime());
  622. }
  623. /* (non-Javadoc)
  624. * @see java.lang.Object#equals(java.lang.Object)
  625. */
  626. @Override
  627. public boolean equals(final Object obj) {
  628. if (this == obj) {
  629. return true;
  630. }
  631. if (obj == null || getClass() != obj.getClass()) {
  632. return false;
  633. }
  634. final ZipEntry other = (ZipEntry) obj;
  635. final String myName = getName();
  636. final String otherName = other.getName();
  637. if (myName == null) {
  638. if (otherName != null) {
  639. return false;
  640. }
  641. } else if (!myName.equals(otherName)) {
  642. return false;
  643. }
  644. String myComment = getComment();
  645. String otherComment = other.getComment();
  646. if (myComment == null) {
  647. myComment = "";
  648. }
  649. if (otherComment == null) {
  650. otherComment = "";
  651. }
  652. return getTime() == other.getTime()
  653. && myComment.equals(otherComment)
  654. && getInternalAttributes() == other.getInternalAttributes()
  655. && getPlatform() == other.getPlatform()
  656. && getExternalAttributes() == other.getExternalAttributes()
  657. && getMethod() == other.getMethod()
  658. && getSize() == other.getSize()
  659. && getCrc() == other.getCrc()
  660. && getCompressedSize() == other.getCompressedSize()
  661. && Arrays.equals(getCentralDirectoryExtra(),
  662. other.getCentralDirectoryExtra())
  663. && Arrays.equals(getLocalFileDataExtra(),
  664. other.getLocalFileDataExtra())
  665. && gpb.equals(other.gpb);
  666. }
  667. }