src/Pure/General/xz.scala
author desharna
Wed, 29 Jun 2022 22:33:08 +0200
changeset 75639 b8bd01897578
parent 75620 44815dc2b8f9
permissions -rw-r--r--
tuned proof

/*  Title:      Pure/General/xz.scala
    Author:     Makarius

Support for XZ data compression.
*/

package isabelle


import org.tukaani.xz.{LZMA2Options, ArrayCache, BasicArrayCache}


object XZ {
  /* options */

  type Options = LZMA2Options

  def options(preset: Int = 3): Options = {
    val opts = new LZMA2Options
    opts.setPreset(preset)
    opts
  }


  /* cache */

  type Cache = ArrayCache

  object Cache {
    def none: ArrayCache = ArrayCache.getDummyCache()
    def apply(): ArrayCache = ArrayCache.getDefaultCache()
    def make(): ArrayCache = new BasicArrayCache
  }


  /* Scala functions in ML */

  object Compress extends Scala.Fun_Bytes("XZ.compress") {
    val here = Scala_Project.here
    def apply(arg: Bytes): Bytes = arg.compress()
  }

  object Uncompress extends Scala.Fun_Bytes("XZ.uncompress") {
    val here = Scala_Project.here
    def apply(arg: Bytes): Bytes = arg.uncompress()
  }
}