| 104 | private fun stripSuffix(name: String): Pair<String, String> { |
| 105 | val at = name.lastIndexOf(".") |
| 106 | if (at == -1) return name to "" |
| 107 | return name.substring(0, at) to name.substring(at, name.length) |
| 108 | } |
| 109 | |
| 110 | fun openInNewProcess(fn: String, workspace: String = FieldBox.workspace) { |
| 111 | |
| 112 | var launcher = System.getenv("FIELD2_LAUNCH") |
| 113 | if (Main.os == Main.OS.mac) { |
| 114 | if (!launcher.endsWith("nodebug")) |
| 115 | launcher = launcher + "_nodebug" |
| 116 | |
| 117 | val u = UUID.randomUUID() |
| 118 | ProcessBuilder().command(launcher, "fieldbox.FieldBox", "-file", fn, "-workspace", workspace) |
| 119 | .redirectError(ProcessBuilder.Redirect.appendTo(File("/var/tmp/field_" + u + "." + fn + ".error.log"))) |
| 120 | .redirectOutput(ProcessBuilder.Redirect.appendTo(File("/var/tmp/field_" + u + "." + fn + ".out.log"))).start() |
| 121 | } |
| 122 | else if (Main.os == Main.OS.windows) |
| 123 | { |
| 124 | val u = UUID.randomUUID() |
| 125 | |
| 126 | println(" does this file exist? ${File("c:\\windows\\system32\\cmd.exe").exists()}") |
| 127 | |
| 128 | val e1 = File.createTempFile("field",".error.log") |
| 129 | val s1 = File.createTempFile("field",".out.log") |
| 130 | |
| 131 | ProcessBuilder().command("c:\\windows\\system32\\cmd.exe", "/c", "start", "\"\"", launcher, "fieldbox.FieldBox", "-file", fn, "-strict", if (Options.dict().isTrue(Dict.Prop<Number>("strict"), false)) "1" else "0", "-workspace", workspace) |
| 132 | .redirectError(ProcessBuilder.Redirect.appendTo(e1)) |
| 133 | .redirectOutput(ProcessBuilder.Redirect.appendTo(s1)).start() |
| 134 | |
| 135 | } |