Packages

o

com.codedx.util

ZipReader

object ZipReader extends Loggable

Utility for reading the contents of a Zip file.

This object provides two methods for reading, each of which manage the opening and closing of filesystem resources so that client code doesn't have to. It also provides a means to simply check if a file is a Zip file or not.

Each of the utility methods can operate on either a String (file path) or File (java.io.File). This is accomplished via the ZipOpenable typeclass defined in this object

Linear Supertypes
Loggable, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. ZipReader
  2. Loggable
  3. AnyRef
  4. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. class Entry extends AnyRef
  2. implicit class RichZipFile extends AnyRef
  3. trait ZipOpenable[T] extends AnyRef

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native() @HotSpotIntrinsicCandidate()
  6. val entryNameCharset: Charset

    The character set used to decode zip entry names.

  7. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  8. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  9. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  10. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  11. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  12. def isZip[T](resource: T)(implicit arg0: ZipOpenable[T]): Boolean
  13. implicit val logger: Logger
    Attributes
    protected
    Definition Classes
    Loggable
    Annotations
    @transient()
  14. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  15. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  16. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  17. def readAsZipFile[T, Result](resource: T)(readZip: (ZipFile) ⇒ Result)(implicit arg0: ZipOpenable[T]): Result

    Read the given resource as a Zip file, passing the actual ZipFile instance to the readZip function before automatically closing it.

  18. def readAsZipStream(rawStream: InputStream): Iterator[(ZipEntry, InputStream)]

    Read the given rawStream as a ZipInputStream, exposing an Iterator over the entries, each paired with their respective contents.

    Read the given rawStream as a ZipInputStream, exposing an Iterator over the entries, each paired with their respective contents. This method DOES NOT automatically close the underlying stream.

  19. def readNestedZip(zipContent: InputStream, depthLimit: Option[Int] = None, zipExtensions: Set[String] = Set("zip", "jar", "war", "ear"), pathFilter: (String) ⇒ Boolean = _ => true, shouldGoDeeper: (List[String]) ⇒ Boolean = _ => true): Iterator[(List[String], InputStream)]

    Reads a zip file that may contain other zip files nested within itself.

    Reads a zip file that may contain other zip files nested within itself. The zipContent is assumed to be a valid zip file; if it isn't, this method will fail.

    zipContent

    An InputStream that represents the content of the zip file being read

    depthLimit

    An optional limit on the number of nesting levels to read. A value of 0 or less implies that the stream should not be read, as the assumption is that zipContent is a zip file, so anything inside of it would have a depth of 1. Default is no limit.

    zipExtensions

    A set of filename extensions (no dot) that signify a nested zip. Default values are "zip", "jar", "war", and "ear".

    pathFilter

    A function that decides whether or not to consider a given entry by its path. Defaults to a function that returns true for all inputs.

    shouldGoDeeper

    A function that decides whether or not explore the children of a (nested) zip. Its only parameter is a list of paths (explained in the return section) to the node in consideration. If shouldGoDeeper(paths) returns true, the reader will continue into that entry's content, yielding their individual paths and contents to the returned iterator. Otherwise, the returned iterator will simply yield the entry itself and not "go deeper".

    returns

    An iterator over each possibly-nested entry in the zip file represented by zipContent, producing a tuple for each entry. The first member of the tuple is a list of paths, representing the current location within the nested zips. For example: "WEB-INF/lib/some-library.jar" :: "com/foo/bar/Stuff.class" :: Nil would represent the "Stuff.class" file, compressed within "some-library.jar", which was encountered in the zipContent. The second member of the tuple is an InputStream containing the contents of that entry.

  20. def readZip[T, Result](resource: T)(readEntries: (List[Entry]) ⇒ Result)(implicit arg0: ZipOpenable[T]): Result

    Read the given resource as a Zip file, using the given readEntries function to generate some Result value.

    Read the given resource as a Zip file, using the given readEntries function to generate some Result value. The entries will be readable *only* during this function; any attempts to do so after this function call will result in IOExceptions because the underlying zip resource will be closed.

  21. def readZipIteratively[T, Result](resource: T)(readEntries: (Iterator[Entry]) ⇒ Result)(implicit arg0: ZipOpenable[T]): Result
  22. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  23. def toString(): String
    Definition Classes
    AnyRef → Any
  24. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  25. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  26. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  27. implicit object fileZipOpenable extends ZipOpenable[File]
  28. implicit object pathZipOpenable extends ZipOpenable[String]

Deprecated Value Members

  1. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] ) @Deprecated
    Deprecated

Inherited from Loggable

Inherited from AnyRef

Inherited from Any

Ungrouped