separate module XZ_File to avoid initial dependency on org.tukaani.xz;
authorwenzelm
Tue, 16 Jul 2013 12:31:08 +0200
changeset 52671 9a360530eac8
parent 52670 57a00f274130
child 52672 8de4235298cb
separate module XZ_File to avoid initial dependency on org.tukaani.xz;
src/Pure/General/file.scala
src/Pure/General/xz_file.scala
src/Pure/build-jars
--- a/src/Pure/General/file.scala	Tue Jul 16 12:25:59 2013 +0200
+++ b/src/Pure/General/file.scala	Tue Jul 16 12:31:08 2013 +0200
@@ -14,8 +14,6 @@
 
 import scala.collection.mutable
 
-import org.tukaani.xz.{LZMA2Options, XZInputStream, XZOutputStream}
-
 
 object File
 {
@@ -77,11 +75,6 @@
 
   def read_gzip(path: Path): String = read_gzip(path.file)
 
-  def read_xz(file: JFile): String =
-    read_stream(new XZInputStream(new BufferedInputStream(new FileInputStream(file))))
-
-  def read_xz(path: Path): String = read_xz(path.file)
-
 
   /* read lines */
 
@@ -113,7 +106,7 @@
 
   /* write */
 
-  private def write_file(file: JFile, text: Iterable[CharSequence],
+  def write_file(file: JFile, text: Iterable[CharSequence],
     make_stream: OutputStream => OutputStream)
   {
     val stream = make_stream(new FileOutputStream(file))
@@ -133,14 +126,6 @@
   def write_gzip(path: Path, text: Iterable[CharSequence]): Unit = write_gzip(path.file, text)
   def write_gzip(path: Path, text: CharSequence): Unit = write_gzip(path.file, text)
 
-  def write_xz(file: JFile, text: Iterable[CharSequence], preset: Int = 3)
-  {
-    val options = new LZMA2Options
-    options.setPreset(preset)
-    write_file(file, text, (s: OutputStream) =>
-      new XZOutputStream(new BufferedOutputStream(s), options))
-  }
-
 
   /* copy */
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/Pure/General/xz_file.scala	Tue Jul 16 12:31:08 2013 +0200
@@ -0,0 +1,31 @@
+/*  Title:      Pure/General/xz_file.scala
+    Author:     Makarius
+
+XZ file system operations.
+*/
+
+package isabelle
+
+
+import java.io.{BufferedOutputStream, OutputStream, FileInputStream, BufferedInputStream,
+  File => JFile}
+
+import org.tukaani.xz.{LZMA2Options, XZInputStream, XZOutputStream}
+
+
+object XZ_File
+{
+  def read(file: JFile): String =
+    File.read_stream(new XZInputStream(new BufferedInputStream(new FileInputStream(file))))
+
+  def read(path: Path): String = read(path.file)
+
+  def write(file: JFile, text: Iterable[CharSequence], preset: Int = 3)
+  {
+    val options = new LZMA2Options
+    options.setPreset(preset)
+    File.write_file(file, text, (s: OutputStream) =>
+      new XZOutputStream(new BufferedOutputStream(s), options))
+  }
+}
+
--- a/src/Pure/build-jars	Tue Jul 16 12:25:59 2013 +0200
+++ b/src/Pure/build-jars	Tue Jul 16 12:31:08 2013 +0200
@@ -27,6 +27,7 @@
   General/symbol.scala
   General/time.scala
   General/timing.scala
+  General/xz_file.scala
   Isar/keyword.scala
   Isar/outer_syntax.scala
   Isar/parse.scala