-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Print exclude list for --all-drives and --drives options, Reduced zip…
… open error, v2.3.4
- Loading branch information
Showing
6 changed files
with
127 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
src/main/java/com/logpresso/scanner/utils/ZipFileIterator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package com.logpresso.scanner.utils; | ||
|
||
import java.io.Closeable; | ||
import java.io.File; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.util.Enumeration; | ||
import java.util.zip.ZipEntry; | ||
import java.util.zip.ZipFile; | ||
import java.util.zip.ZipInputStream; | ||
|
||
public class ZipFileIterator implements Closeable { | ||
|
||
private ZipFile zipFile; | ||
private ZipInputStream zis; | ||
private Enumeration<? extends ZipEntry> e; | ||
private ZipEntry nextEntry; | ||
|
||
public ZipFileIterator(File file) throws IOException { | ||
this.zipFile = new ZipFile(file); | ||
e = zipFile.entries(); | ||
} | ||
|
||
public ZipFileIterator(ZipInputStream zis) { | ||
this.zis = zis; | ||
} | ||
|
||
public ZipEntry getNextEntry() throws IOException { | ||
if (zipFile != null) { | ||
if (e.hasMoreElements()) { | ||
this.nextEntry = e.nextElement(); | ||
return nextEntry; | ||
} else { | ||
return null; | ||
} | ||
} else { | ||
this.nextEntry = zis.getNextEntry(); | ||
return nextEntry; | ||
} | ||
} | ||
|
||
public InputStream getNextInputStream() throws IOException { | ||
if (zipFile != null) | ||
return zipFile.getInputStream(nextEntry); | ||
|
||
return zis; | ||
} | ||
|
||
public void close() throws IOException { | ||
if (zipFile != null) | ||
zipFile.close(); | ||
|
||
if (zis != null) | ||
IoUtils.ensureClose(zis); | ||
} | ||
|
||
} |