Skip to content
This repository has been archived by the owner on Nov 2, 2021. It is now read-only.

Commit

Permalink
zip input stream hot fix
Browse files Browse the repository at this point in the history
  • Loading branch information
sokomishalov committed Sep 20, 2019
1 parent 9323700 commit 6ecdc72
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ import org.apache.commons.io.IOUtils.toByteArray as iOUtilsToByteArray
fun InputStream.toByteArray(): ByteArray = iOUtilsToByteArray(this)

fun ZipInputStream.toIterableEntries(): Iterable<ZipEntry> = object : Iterable<ZipEntry> {
override fun iterator(): Iterator<ZipEntry> {
return object : Iterator<ZipEntry> {
var next: ZipEntry? = nextEntry
override fun iterator(): Iterator<ZipEntry> = object : Iterator<ZipEntry> {
var next: ZipEntry? = null

override operator fun hasNext() = next != null
override operator fun next(): ZipEntry {
val tmp = next ?: throw NoSuchElementException()
next = nextEntry
return tmp
}
override operator fun hasNext(): Boolean {
next = nextEntry
return next != null
}

override operator fun next(): ZipEntry {
return next ?: throw NoSuchElementException()
}
}
}

0 comments on commit 6ecdc72

Please sign in to comment.