• R/O
  • HTTP
  • SSH
  • HTTPS

dictzip-java: Commit


Commit MetaInfo

Revision38deeb23222da790575bbe2dbf1988af94653257 (tree)
Zeit2022-02-04 23:44:26
AutorHiroshi Miura <miurahr@linu...>
CommiterHiroshi Miura

Log Message

Move checkDictZipInputStream

Introduce DictZipFiles.checkDictZipFile and
DictZipFiles.checkDictZipInputStream
Deprecate DictZipFileUtils.check* methods.

Signed-off-by: Hiroshi Miura <miurahr@linux.com>

Ändern Zusammenfassung

Diff

--- a/dictzip-cli/src/main/java/org/dict/zip/cli/Main.java
+++ b/dictzip-cli/src/main/java/org/dict/zip/cli/Main.java
@@ -3,7 +3,7 @@
33 *
44 * This is a part of DictZip-java library.
55 *
6- * Copyright (C) 2016 Hiroshi Miura
6+ * Copyright (C) 2016,2022 Hiroshi Miura
77 *
88 * This program is free software; you can redistribute it and/or
99 * modify it under the terms of the GNU General Public License
@@ -22,7 +22,7 @@
2222
2323 package org.dict.zip.cli;
2424
25-import org.dict.zip.DictZipFileUtils;
25+import org.dict.zip.DictZipFiles;
2626 import org.dict.zip.DictZipHeader.CompressionLevel;
2727
2828 import java.io.File;
@@ -67,7 +67,7 @@ public final class Main {
6767 } else if (commandLine.options.isTest()) {
6868 boolean result = false;
6969 try {
70- result = DictZipFileUtils.checkDictZipInputStream(fName);
70+ result = DictZipFiles.checkDictZipFile(fName);
7171 } catch (IOException e) {
7272 System.err.println(e.getMessage());
7373 System.exit(2);
--- a/dictzip-lib/src/main/java/org/dict/zip/DictZipFileUtils.java
+++ b/dictzip-lib/src/main/java/org/dict/zip/DictZipFileUtils.java
@@ -79,41 +79,26 @@ public final class DictZipFileUtils {
7979
8080 /**
8181 * Check gzip member stream w/ CRC and length in trailer.
82+ * @see DictZipFiles#checkDictZipFile
8283 * @param filename to be checked.
8384 * @return true if it is a valid dictzip file, otherwise false.
8485 * @throws IOException when CRC error or total length error.
8586 */
87+ @Deprecated
8688 public static boolean checkDictZipInputStream(final String filename) throws IOException {
87- boolean result;
88- try (DictZipInputStream dzin = new DictZipInputStream(new
89- RandomAccessInputStream(filename, "r"))) {
90- result = checkDictZipInputStream(dzin);
91- dzin.close();
92- }
93- return result;
89+ return DictZipFiles.checkDictZipFile(filename);
9490 }
9591
9692 /**
9793 * Check gzip member stream w/ CRC and length in trailer.
94+ * @see DictZipFiles#checkDictZipInputStream
9895 * @param in inputstream to be checked.
9996 * @return true if inputstream is a valid dictzip, otherwise false.
10097 * @throws IOException when CRC error or total length error.
10198 */
99+ @Deprecated
102100 public static boolean checkDictZipInputStream(final DictZipInputStream in) throws IOException {
103- byte[] tmpBuf = new byte[CHECK_BUF_LEN];
104- in.seek(0);
105- long readLen = 0;
106- while (readLen < in.getLength()) {
107- int len = in.read(tmpBuf, 0, CHECK_BUF_LEN);
108- if (len < 0) {
109- break;
110- }
111- readLen += len;
112- }
113- if (readLen != in.getLength()) {
114- return false;
115- }
116- return true;
101+ return DictZipFiles.checkDictZipInputStream(in);
117102 }
118103
119104 private DictZipFileUtils() {
Show on old repository browser