# Class MPackageReader

java.lang.Object
com.io7m.montarre.io.internal.MPackageReader

All Implemented Interfaces:
  `MPackageReaderType`, `AutoCloseable`

public final class MPackageReader extends Object implements MPackageReaderType
A package reader.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `MPackageReader(Path file, org.apache.commons.compress.archivers.zip.ZipFile inZipFile, MPackageDeclarationParserFactoryType inParsers)`
  A package reader.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `checkHash(MFileName file)`
  Check the digest of the given file, raising an exception if it does not match what is in the package declaration.
  `void`
  `close()`
  `MPackageDeclaration`
  `packageDeclaration()`
  `InputStream`
  `readFile(MFileName file)`
  `void`
  `start()`
  Open the package declaration and parse it.
  `void`
  `unpackInto(Path output)`
  Unpack all files into the given output directory.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### MPackageReader

    public MPackageReader(Path file, org.apache.commons.compress.archivers.zip.ZipFile inZipFile, MPackageDeclarationParserFactoryType inParsers)
    A package reader.
    Parameters:
      `file` - The file
      `inZipFile` - The zip file
      `inParsers` - The parsers

- ## Method Details

  - ### start

    public void start() throws MException
    Open the package declaration and parse it.
    Throws:
      `MException` - On errors

  - ### packageDeclaration

    public MPackageDeclaration packageDeclaration()
    Specified by:
      `packageDeclaration` in interface `MPackageReaderType`
    Returns:
      The package declaration

  - ### close

    public void close() throws MException
    Specified by:
      `close` in interface `AutoCloseable`
    Specified by:
      `close` in interface `MPackageReaderType`
    Throws:
      `MException`

  - ### readFile

    public InputStream readFile(MFileName file) throws MException
    Specified by:
      `readFile` in interface `MPackageReaderType`
    Parameters:
      `file` - The file
    Returns:
      A stream for the given file
    Throws:
      `MException`

  - ### checkHash

    public void checkHash(MFileName file) throws MException
    Description copied from interface: `MPackageReaderType`
    Check the digest of the given file, raising an exception if it does not match what is in the package declaration.
    Specified by:
      `checkHash` in interface `MPackageReaderType`
    Parameters:
      `file` - The file
    Throws:
      `MException` - On errors

  - ### unpackInto

    public void unpackInto(Path output) throws MException
    Description copied from interface: `MPackageReaderType`
    Unpack all files into the given output directory.
    Specified by:
      `unpackInto` in interface `MPackageReaderType`
    Parameters:
      `output` - The output directory
    Throws:
      `MException` - On errors