# 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.

- ## Nested Class Summary

  ### Nested classes/interfaces inherited from interface MPackageReaderType

  `MPackageReaderType.PlatformDependentModulePolicy`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `MPackageReader(Path inFile, MPackageDeclarationParserFactoryType inParsers)`
  A package reader.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `checkHash(MFileName fileName)`
  Check the digest of the given file, raising an exception if it does not match what is in the package declaration.
  `void`
  `close()`
  `static byte[]`
  `extractManifest(Path file)`
  Extract a manifest from the file.
  `MPackageDeclaration`
  `packageDeclaration()`
  `InputStream`
  `readFile(MFileName fileName)`
  `void`
  `start()`
  Open the package declaration and parse it.
  `void`
  `unpackInto(Path output, Function<MPlatformDependentModule, MPackageReaderType.PlatformDependentModulePolicy> filterPlatform)`
  Unpack all files into the given output directory.

  ### Methods inherited from class Object

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

  ### Methods inherited from interface MPackageReaderType

  `unpackInto`

- ## Constructor Details

  - ### MPackageReader

    public MPackageReader(Path inFile, MPackageDeclarationParserFactoryType inParsers) throws IOException, com.io7m.entomos.core.EoException
    A package reader.
    Parameters:
      `inFile` - The file
      `inParsers` - The parsers
    Throws:
      `IOException`
      `com.io7m.entomos.core.EoException`

- ## Method Details

  - ### extractManifest

    public static byte[] extractManifest(Path file) throws MException
    Extract a manifest from the file.
    Parameters:
      `file` - The file
    Returns:
      The manifest bytes
    Throws:
      `MException` - On errors

  - ### 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 fileName) throws MException
    Specified by:
      `readFile` in interface `MPackageReaderType`
    Parameters:
      `fileName` - The file
    Returns:
      A stream for the given file
    Throws:
      `MException` - On errors

  - ### checkHash

    public void checkHash(MFileName fileName) 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:
      `fileName` - The file
    Throws:
      `MException` - On errors

  - ### unpackInto

    public void unpackInto(Path output, Function<MPlatformDependentModule, MPackageReaderType.PlatformDependentModulePolicy> filterPlatform) 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
      `filterPlatform` - The filter for platform-dependent modules
    Throws:
      `MException` - On errors