some more options to robustify posix_untar;
authorwenzelm
Mon, 27 Sep 2010 14:34:55 +0200
changeset 39709 1fa4c5c7d534
parent 39708 c3239be617f4
child 39729 6a64f04cb648
some more options to robustify posix_untar;
src/Pure/System/standard_system.scala
--- a/src/Pure/System/standard_system.scala	Mon Sep 27 13:38:35 2010 +0200
+++ b/src/Pure/System/standard_system.scala	Mon Sep 27 14:34:55 2010 +0200
@@ -160,7 +160,7 @@
   /* unpack tar archive */
 
   def posix_untar(url: URL, root: File, gunzip: Boolean = false,
-    tar: String = "tar", progress: Int => Unit = _ => ()): String =
+    tar: String = "tar", gzip: String = "", progress: Int => Unit = _ => ()): String =
   {
     if (!root.isDirectory && !root.mkdirs)
       error("Failed to create root directory: " + root)
@@ -189,7 +189,11 @@
       override def close() { stream.close }
     }
 
-    val proc = raw_execute(root, null, false, tar, if (gunzip) "-xz" else "-x", "-f-")
+    val cmdline =
+      List(tar, "-o", "-x", "-f-") :::
+        (if (!gunzip) Nil else if (gzip == "") List("-z") else List("-I", gzip))
+
+    val proc = raw_execute(root, null, false, cmdline:_*)
     val stdout = Simple_Thread.future("tar_stdout") { slurp(proc.getInputStream) }
     val stderr = Simple_Thread.future("tar_stderr") { slurp(proc.getErrorStream) }
     val stdin = new BufferedOutputStream(proc.getOutputStream)