src/Pure/System/standard_system.scala
author wenzelm
Sun, 26 Sep 2010 23:35:10 +0200
changeset 39706 6e74fb2d4374
parent 39705 41e9f69c553d
child 39708 c3239be617f4
permissions -rw-r--r--
raw_untar.raw_execute with native cwd, to avoid cross-platform complications; more informative treatment of IOException, notably due to broken pipe;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
34201
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
     1
/*  Title:      Pure/System/standard_system.scala
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
     2
    Author:     Makarius
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
     3
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
     4
Standard system operations, with basic Cygwin/Posix compatibility.
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
     5
*/
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
     6
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
     7
package isabelle
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
     8
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
     9
import java.util.regex.Pattern
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
    10
import java.util.Locale
39705
41e9f69c553d added Standard_System.raw_untar;
wenzelm
parents: 39582
diff changeset
    11
import java.util.zip.GZIPInputStream
41e9f69c553d added Standard_System.raw_untar;
wenzelm
parents: 39582
diff changeset
    12
import java.net.URL
41e9f69c553d added Standard_System.raw_untar;
wenzelm
parents: 39582
diff changeset
    13
import java.io.{BufferedWriter, OutputStreamWriter, FileOutputStream, BufferedOutputStream,
39578
b75164153c37 added Standard_System.slurp convenience;
wenzelm
parents: 39522
diff changeset
    14
  BufferedInputStream, InputStream, FileInputStream, BufferedReader, InputStreamReader,
34298
13e9f1f4acd9 added find_files;
wenzelm
parents: 34258
diff changeset
    15
  File, FileFilter, IOException}
34201
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
    16
36011
3ff725ac13a4 adapted to Scala 2.8.0 Beta1 -- with notable changes to scala.collection;
wenzelm
parents: 34300
diff changeset
    17
import scala.io.{Source, Codec}
34201
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
    18
import scala.util.matching.Regex
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
    19
import scala.collection.mutable
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
    20
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
    21
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
    22
object Standard_System
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
    23
{
38264
205b74a1bb18 added string_bytes convenience;
wenzelm
parents: 36193
diff changeset
    24
  /* UTF-8 charset */
205b74a1bb18 added string_bytes convenience;
wenzelm
parents: 36193
diff changeset
    25
34201
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
    26
  val charset = "UTF-8"
36015
6111de7c916a adapted to Scala 2.8.0 Beta 1;
wenzelm
parents: 36011
diff changeset
    27
  def codec(): Codec = Codec(charset)
34201
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
    28
38264
205b74a1bb18 added string_bytes convenience;
wenzelm
parents: 36193
diff changeset
    29
  def string_bytes(s: String): Array[Byte] = s.getBytes(charset)
205b74a1bb18 added string_bytes convenience;
wenzelm
parents: 36193
diff changeset
    30
34201
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
    31
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
    32
  /* permissive UTF-8 decoding */
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
    33
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
    34
  // see also http://en.wikipedia.org/wiki/UTF-8#Description
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
    35
  // overlong encodings enable byte-stuffing
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
    36
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
    37
  def decode_permissive_utf8(text: CharSequence): String =
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
    38
  {
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
    39
    val buf = new java.lang.StringBuilder(text.length)
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
    40
    var code = -1
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
    41
    var rest = 0
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
    42
    def flush()
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
    43
    {
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
    44
      if (code != -1) {
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
    45
        if (rest == 0 && Character.isValidCodePoint(code))
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
    46
          buf.appendCodePoint(code)
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
    47
        else buf.append('\uFFFD')
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
    48
        code = -1
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
    49
        rest = 0
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
    50
      }
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
    51
    }
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
    52
    def init(x: Int, n: Int)
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
    53
    {
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
    54
      flush()
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
    55
      code = x
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
    56
      rest = n
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
    57
    }
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
    58
    def push(x: Int)
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
    59
    {
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
    60
      if (rest <= 0) init(x, -1)
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
    61
      else {
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
    62
        code <<= 6
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
    63
        code += x
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
    64
        rest -= 1
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
    65
      }
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
    66
    }
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
    67
    for (i <- 0 until text.length) {
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
    68
      val c = text.charAt(i)
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
    69
      if (c < 128) { flush(); buf.append(c) }
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
    70
      else if ((c & 0xC0) == 0x80) push(c & 0x3F)
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
    71
      else if ((c & 0xE0) == 0xC0) init(c & 0x1F, 1)
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
    72
      else if ((c & 0xF0) == 0xE0) init(c & 0x0F, 2)
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
    73
      else if ((c & 0xF8) == 0xF0) init(c & 0x07, 3)
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
    74
    }
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
    75
    flush()
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
    76
    buf.toString
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
    77
  }
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
    78
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
    79
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
    80
  /* basic file operations */
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
    81
39578
b75164153c37 added Standard_System.slurp convenience;
wenzelm
parents: 39522
diff changeset
    82
  def slurp(reader: BufferedReader): String =
34201
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
    83
  {
39578
b75164153c37 added Standard_System.slurp convenience;
wenzelm
parents: 39522
diff changeset
    84
    val output = new StringBuilder(100)
b75164153c37 added Standard_System.slurp convenience;
wenzelm
parents: 39522
diff changeset
    85
    var c = -1
b75164153c37 added Standard_System.slurp convenience;
wenzelm
parents: 39522
diff changeset
    86
    while ({ c = reader.read; c != -1 }) output += c.toChar
b75164153c37 added Standard_System.slurp convenience;
wenzelm
parents: 39522
diff changeset
    87
    reader.close
b75164153c37 added Standard_System.slurp convenience;
wenzelm
parents: 39522
diff changeset
    88
    output.toString
34201
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
    89
  }
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
    90
39578
b75164153c37 added Standard_System.slurp convenience;
wenzelm
parents: 39522
diff changeset
    91
  def slurp(stream: InputStream): String =
b75164153c37 added Standard_System.slurp convenience;
wenzelm
parents: 39522
diff changeset
    92
    slurp(new BufferedReader(new InputStreamReader(stream, charset)))
b75164153c37 added Standard_System.slurp convenience;
wenzelm
parents: 39522
diff changeset
    93
b75164153c37 added Standard_System.slurp convenience;
wenzelm
parents: 39522
diff changeset
    94
  def read_file(file: File): String = slurp(new FileInputStream(file))
34201
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
    95
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
    96
  def write_file(file: File, text: CharSequence)
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
    97
  {
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
    98
    val writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), charset))
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
    99
    try { writer.append(text) }
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   100
    finally { writer.close }
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   101
  }
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   102
39578
b75164153c37 added Standard_System.slurp convenience;
wenzelm
parents: 39522
diff changeset
   103
  def with_tmp_file[A](prefix: String)(body: File => A): A =
b75164153c37 added Standard_System.slurp convenience;
wenzelm
parents: 39522
diff changeset
   104
  {
b75164153c37 added Standard_System.slurp convenience;
wenzelm
parents: 39522
diff changeset
   105
    val file = File.createTempFile(prefix, null)
39582
a873158542d0 Standard_System.with_tmp_file: deleteOnExit to make double sure;
wenzelm
parents: 39578
diff changeset
   106
    file.deleteOnExit
39578
b75164153c37 added Standard_System.slurp convenience;
wenzelm
parents: 39522
diff changeset
   107
    try { body(file) } finally { file.delete }
b75164153c37 added Standard_System.slurp convenience;
wenzelm
parents: 39522
diff changeset
   108
  }
b75164153c37 added Standard_System.slurp convenience;
wenzelm
parents: 39522
diff changeset
   109
34300
3f2e25dc99ab misc tuning;
wenzelm
parents: 34298
diff changeset
   110
  // FIXME handle (potentially cyclic) directory graph
34298
13e9f1f4acd9 added find_files;
wenzelm
parents: 34258
diff changeset
   111
  def find_files(start: File, ok: File => Boolean): List[File] =
13e9f1f4acd9 added find_files;
wenzelm
parents: 34258
diff changeset
   112
  {
13e9f1f4acd9 added find_files;
wenzelm
parents: 34258
diff changeset
   113
    val files = new mutable.ListBuffer[File]
13e9f1f4acd9 added find_files;
wenzelm
parents: 34258
diff changeset
   114
    val filter = new FileFilter { def accept(entry: File) = entry.isDirectory || ok(entry) }
13e9f1f4acd9 added find_files;
wenzelm
parents: 34258
diff changeset
   115
    def find_entry(entry: File)
13e9f1f4acd9 added find_files;
wenzelm
parents: 34258
diff changeset
   116
    {
13e9f1f4acd9 added find_files;
wenzelm
parents: 34258
diff changeset
   117
      if (ok(entry)) files += entry
13e9f1f4acd9 added find_files;
wenzelm
parents: 34258
diff changeset
   118
      if (entry.isDirectory) entry.listFiles(filter).foreach(find_entry)
13e9f1f4acd9 added find_files;
wenzelm
parents: 34258
diff changeset
   119
    }
13e9f1f4acd9 added find_files;
wenzelm
parents: 34258
diff changeset
   120
    find_entry(start)
13e9f1f4acd9 added find_files;
wenzelm
parents: 34258
diff changeset
   121
    files.toList
13e9f1f4acd9 added find_files;
wenzelm
parents: 34258
diff changeset
   122
  }
13e9f1f4acd9 added find_files;
wenzelm
parents: 34258
diff changeset
   123
34201
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   124
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   125
  /* shell processes */
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   126
34219
d37cfca69887 Standard_System.raw_execute: optional cwd;
wenzelm
parents: 34202
diff changeset
   127
  def raw_execute(cwd: File, env: Map[String, String], redirect: Boolean, args: String*): Process =
34201
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   128
  {
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   129
    val cmdline = new java.util.LinkedList[String]
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   130
    for (s <- args) cmdline.add(s)
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   131
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   132
    val proc = new ProcessBuilder(cmdline)
34219
d37cfca69887 Standard_System.raw_execute: optional cwd;
wenzelm
parents: 34202
diff changeset
   133
    if (cwd != null) proc.directory(cwd)
34202
99241daf807d ignore undefined environment;
wenzelm
parents: 34201
diff changeset
   134
    if (env != null) {
99241daf807d ignore undefined environment;
wenzelm
parents: 34201
diff changeset
   135
      proc.environment.clear
99241daf807d ignore undefined environment;
wenzelm
parents: 34201
diff changeset
   136
      for ((x, y) <- env) proc.environment.put(x, y)
99241daf807d ignore undefined environment;
wenzelm
parents: 34201
diff changeset
   137
    }
34201
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   138
    proc.redirectErrorStream(redirect)
39522
01aade784da9 raw_execute: let IOException pass-through unhindered (again);
wenzelm
parents: 38264
diff changeset
   139
    proc.start
34201
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   140
  }
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   141
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   142
  def process_output(proc: Process): (String, Int) =
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   143
  {
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   144
    proc.getOutputStream.close
39578
b75164153c37 added Standard_System.slurp convenience;
wenzelm
parents: 39522
diff changeset
   145
    val output = slurp(proc.getInputStream)
34201
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   146
    val rc =
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   147
      try { proc.waitFor }
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   148
      finally {
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   149
        proc.getInputStream.close
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   150
        proc.getErrorStream.close
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   151
        proc.destroy
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   152
        Thread.interrupted
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   153
      }
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   154
    (output, rc)
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   155
  }
34258
e936d3c35ce0 Standard_System.raw_exec;
wenzelm
parents: 34219
diff changeset
   156
39522
01aade784da9 raw_execute: let IOException pass-through unhindered (again);
wenzelm
parents: 38264
diff changeset
   157
  def raw_exec(cwd: File, env: Map[String, String], redirect: Boolean, args: String*)
01aade784da9 raw_execute: let IOException pass-through unhindered (again);
wenzelm
parents: 38264
diff changeset
   158
    : (String, Int) = process_output(raw_execute(cwd, env, redirect, args: _*))
39705
41e9f69c553d added Standard_System.raw_untar;
wenzelm
parents: 39582
diff changeset
   159
41e9f69c553d added Standard_System.raw_untar;
wenzelm
parents: 39582
diff changeset
   160
41e9f69c553d added Standard_System.raw_untar;
wenzelm
parents: 39582
diff changeset
   161
  /* unpack tar.gz */
41e9f69c553d added Standard_System.raw_untar;
wenzelm
parents: 39582
diff changeset
   162
41e9f69c553d added Standard_System.raw_untar;
wenzelm
parents: 39582
diff changeset
   163
  def raw_untar(url: URL, root: File,
41e9f69c553d added Standard_System.raw_untar;
wenzelm
parents: 39582
diff changeset
   164
    tar: String = "tar", progress: Int => Unit = _ => ()): String =
41e9f69c553d added Standard_System.raw_untar;
wenzelm
parents: 39582
diff changeset
   165
  {
41e9f69c553d added Standard_System.raw_untar;
wenzelm
parents: 39582
diff changeset
   166
    if (!root.isDirectory && !root.mkdirs) error("Failed to create root directory: " + root)
41e9f69c553d added Standard_System.raw_untar;
wenzelm
parents: 39582
diff changeset
   167
41e9f69c553d added Standard_System.raw_untar;
wenzelm
parents: 39582
diff changeset
   168
    val connection = url.openConnection
41e9f69c553d added Standard_System.raw_untar;
wenzelm
parents: 39582
diff changeset
   169
41e9f69c553d added Standard_System.raw_untar;
wenzelm
parents: 39582
diff changeset
   170
    val length = connection.getContentLength.toLong
41e9f69c553d added Standard_System.raw_untar;
wenzelm
parents: 39582
diff changeset
   171
    require(length >= 0L)
41e9f69c553d added Standard_System.raw_untar;
wenzelm
parents: 39582
diff changeset
   172
41e9f69c553d added Standard_System.raw_untar;
wenzelm
parents: 39582
diff changeset
   173
    val buffered_stream = new BufferedInputStream(connection.getInputStream)
41e9f69c553d added Standard_System.raw_untar;
wenzelm
parents: 39582
diff changeset
   174
    val progress_stream = new InputStream {
41e9f69c553d added Standard_System.raw_untar;
wenzelm
parents: 39582
diff changeset
   175
      private val total = length max 1L
41e9f69c553d added Standard_System.raw_untar;
wenzelm
parents: 39582
diff changeset
   176
      private var index = 0L
41e9f69c553d added Standard_System.raw_untar;
wenzelm
parents: 39582
diff changeset
   177
      private var percentage = 0L
41e9f69c553d added Standard_System.raw_untar;
wenzelm
parents: 39582
diff changeset
   178
      override def read(): Int =
41e9f69c553d added Standard_System.raw_untar;
wenzelm
parents: 39582
diff changeset
   179
      {
41e9f69c553d added Standard_System.raw_untar;
wenzelm
parents: 39582
diff changeset
   180
        val c = buffered_stream.read
41e9f69c553d added Standard_System.raw_untar;
wenzelm
parents: 39582
diff changeset
   181
        if (c != -1) {
41e9f69c553d added Standard_System.raw_untar;
wenzelm
parents: 39582
diff changeset
   182
          index += 100
41e9f69c553d added Standard_System.raw_untar;
wenzelm
parents: 39582
diff changeset
   183
          val p = index / total
41e9f69c553d added Standard_System.raw_untar;
wenzelm
parents: 39582
diff changeset
   184
          if (percentage != p) { percentage = p; progress(percentage.toInt) }
41e9f69c553d added Standard_System.raw_untar;
wenzelm
parents: 39582
diff changeset
   185
        }
41e9f69c553d added Standard_System.raw_untar;
wenzelm
parents: 39582
diff changeset
   186
        c
41e9f69c553d added Standard_System.raw_untar;
wenzelm
parents: 39582
diff changeset
   187
      }
41e9f69c553d added Standard_System.raw_untar;
wenzelm
parents: 39582
diff changeset
   188
      override def close() { buffered_stream.close }
41e9f69c553d added Standard_System.raw_untar;
wenzelm
parents: 39582
diff changeset
   189
    }
41e9f69c553d added Standard_System.raw_untar;
wenzelm
parents: 39582
diff changeset
   190
    val gzip_stream = new GZIPInputStream(progress_stream)
41e9f69c553d added Standard_System.raw_untar;
wenzelm
parents: 39582
diff changeset
   191
39706
6e74fb2d4374 raw_untar.raw_execute with native cwd, to avoid cross-platform complications;
wenzelm
parents: 39705
diff changeset
   192
    val proc = raw_execute(root, null, false, tar, "-x", "-f", "-")
39705
41e9f69c553d added Standard_System.raw_untar;
wenzelm
parents: 39582
diff changeset
   193
    val stdout = Simple_Thread.future("tar_stdout") { slurp(proc.getInputStream) }
41e9f69c553d added Standard_System.raw_untar;
wenzelm
parents: 39582
diff changeset
   194
    val stderr = Simple_Thread.future("tar_stderr") { slurp(proc.getErrorStream) }
41e9f69c553d added Standard_System.raw_untar;
wenzelm
parents: 39582
diff changeset
   195
    val stdin = new BufferedOutputStream(proc.getOutputStream)
41e9f69c553d added Standard_System.raw_untar;
wenzelm
parents: 39582
diff changeset
   196
41e9f69c553d added Standard_System.raw_untar;
wenzelm
parents: 39582
diff changeset
   197
    try {
41e9f69c553d added Standard_System.raw_untar;
wenzelm
parents: 39582
diff changeset
   198
      var c = -1
39706
6e74fb2d4374 raw_untar.raw_execute with native cwd, to avoid cross-platform complications;
wenzelm
parents: 39705
diff changeset
   199
      val io_err =
6e74fb2d4374 raw_untar.raw_execute with native cwd, to avoid cross-platform complications;
wenzelm
parents: 39705
diff changeset
   200
        try { while ({ c = gzip_stream.read; c != -1 }) stdin.write(c); false }
6e74fb2d4374 raw_untar.raw_execute with native cwd, to avoid cross-platform complications;
wenzelm
parents: 39705
diff changeset
   201
        catch { case e: IOException => true }
39705
41e9f69c553d added Standard_System.raw_untar;
wenzelm
parents: 39582
diff changeset
   202
      stdin.close
41e9f69c553d added Standard_System.raw_untar;
wenzelm
parents: 39582
diff changeset
   203
41e9f69c553d added Standard_System.raw_untar;
wenzelm
parents: 39582
diff changeset
   204
      val rc = try { proc.waitFor } finally { Thread.interrupted }
39706
6e74fb2d4374 raw_untar.raw_execute with native cwd, to avoid cross-platform complications;
wenzelm
parents: 39705
diff changeset
   205
      if (io_err || rc != 0) error(stderr.join.trim) else stdout.join
39705
41e9f69c553d added Standard_System.raw_untar;
wenzelm
parents: 39582
diff changeset
   206
    }
41e9f69c553d added Standard_System.raw_untar;
wenzelm
parents: 39582
diff changeset
   207
    finally {
41e9f69c553d added Standard_System.raw_untar;
wenzelm
parents: 39582
diff changeset
   208
      gzip_stream.close
41e9f69c553d added Standard_System.raw_untar;
wenzelm
parents: 39582
diff changeset
   209
      stdin.close
41e9f69c553d added Standard_System.raw_untar;
wenzelm
parents: 39582
diff changeset
   210
      proc.destroy
41e9f69c553d added Standard_System.raw_untar;
wenzelm
parents: 39582
diff changeset
   211
    }
41e9f69c553d added Standard_System.raw_untar;
wenzelm
parents: 39582
diff changeset
   212
  }
34201
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   213
}
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   214
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   215
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   216
class Standard_System
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   217
{
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   218
  val platform_root = if (Platform.is_windows) Cygwin.check_root() else "/"
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   219
  override def toString = platform_root
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   220
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   221
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   222
  /* jvm_path */
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   223
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   224
  private val Cygdrive = new Regex("/cygdrive/([a-zA-Z])($|/.*)")
36136
89b1a136edef more precise treatment of UNC server prefix, e.g. //foo;
wenzelm
parents: 36015
diff changeset
   225
  private val Named_Root = new Regex("//+([^/]*)(.*)")
34201
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   226
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   227
  def jvm_path(posix_path: String): String =
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   228
    if (Platform.is_windows) {
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   229
      val result_path = new StringBuilder
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   230
      val rest =
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   231
        posix_path match {
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   232
          case Cygdrive(drive, rest) =>
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   233
            result_path ++= (drive + ":" + File.separator)
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   234
            rest
36136
89b1a136edef more precise treatment of UNC server prefix, e.g. //foo;
wenzelm
parents: 36015
diff changeset
   235
          case Named_Root(root, rest) =>
89b1a136edef more precise treatment of UNC server prefix, e.g. //foo;
wenzelm
parents: 36015
diff changeset
   236
            result_path ++= File.separator
89b1a136edef more precise treatment of UNC server prefix, e.g. //foo;
wenzelm
parents: 36015
diff changeset
   237
            result_path ++= File.separator
89b1a136edef more precise treatment of UNC server prefix, e.g. //foo;
wenzelm
parents: 36015
diff changeset
   238
            result_path ++= root
89b1a136edef more precise treatment of UNC server prefix, e.g. //foo;
wenzelm
parents: 36015
diff changeset
   239
            rest
34201
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   240
          case path if path.startsWith("/") =>
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   241
            result_path ++= platform_root
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   242
            path
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   243
          case path => path
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   244
        }
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   245
      for (p <- rest.split("/") if p != "") {
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   246
        val len = result_path.length
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   247
        if (len > 0 && result_path(len - 1) != File.separatorChar)
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   248
          result_path += File.separatorChar
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   249
        result_path ++= p
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   250
      }
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   251
      result_path.toString
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   252
    }
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   253
    else posix_path
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   254
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   255
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   256
  /* posix_path */
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   257
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   258
  private val Platform_Root = new Regex("(?i)" +
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   259
    Pattern.quote(platform_root) + """(?:\\+|\z)(.*)""")
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   260
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   261
  private val Drive = new Regex("""([a-zA-Z]):\\*(.*)""")
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   262
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   263
  def posix_path(jvm_path: String): String =
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   264
    if (Platform.is_windows) {
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   265
      jvm_path.replace('/', '\\') match {
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   266
        case Platform_Root(rest) => "/" + rest.replace('\\', '/')
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   267
        case Drive(letter, rest) =>
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   268
          "/cygdrive/" + letter.toLowerCase(Locale.ENGLISH) +
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   269
            (if (rest == "") "" else "/" + rest.replace('\\', '/'))
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   270
        case path => path.replace('\\', '/')
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   271
      }
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   272
    }
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   273
    else jvm_path
36193
067a01827fca improved ISABELLE_JAVA, based on THIS_JAVA of the actually running JVM;
wenzelm
parents: 36136
diff changeset
   274
067a01827fca improved ISABELLE_JAVA, based on THIS_JAVA of the actually running JVM;
wenzelm
parents: 36136
diff changeset
   275
067a01827fca improved ISABELLE_JAVA, based on THIS_JAVA of the actually running JVM;
wenzelm
parents: 36136
diff changeset
   276
  /* this_java executable */
067a01827fca improved ISABELLE_JAVA, based on THIS_JAVA of the actually running JVM;
wenzelm
parents: 36136
diff changeset
   277
067a01827fca improved ISABELLE_JAVA, based on THIS_JAVA of the actually running JVM;
wenzelm
parents: 36136
diff changeset
   278
  def this_java(): String =
067a01827fca improved ISABELLE_JAVA, based on THIS_JAVA of the actually running JVM;
wenzelm
parents: 36136
diff changeset
   279
  {
067a01827fca improved ISABELLE_JAVA, based on THIS_JAVA of the actually running JVM;
wenzelm
parents: 36136
diff changeset
   280
    val java_home = System.getProperty("java.home")
067a01827fca improved ISABELLE_JAVA, based on THIS_JAVA of the actually running JVM;
wenzelm
parents: 36136
diff changeset
   281
    val java_exe =
067a01827fca improved ISABELLE_JAVA, based on THIS_JAVA of the actually running JVM;
wenzelm
parents: 36136
diff changeset
   282
      if (Platform.is_windows) new File(java_home + "\\bin\\java.exe")
067a01827fca improved ISABELLE_JAVA, based on THIS_JAVA of the actually running JVM;
wenzelm
parents: 36136
diff changeset
   283
      else new File(java_home + "/bin/java")
067a01827fca improved ISABELLE_JAVA, based on THIS_JAVA of the actually running JVM;
wenzelm
parents: 36136
diff changeset
   284
    if (!java_exe.isFile) error("Expected this Java executable: " + java_exe.toString)
067a01827fca improved ISABELLE_JAVA, based on THIS_JAVA of the actually running JVM;
wenzelm
parents: 36136
diff changeset
   285
    posix_path(java_exe.getAbsolutePath)
067a01827fca improved ISABELLE_JAVA, based on THIS_JAVA of the actually running JVM;
wenzelm
parents: 36136
diff changeset
   286
  }
34201
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
diff changeset
   287
}