| 67 | |
| 68 | var started: Boolean = false |
| 69 | |
| 70 | @JvmStatic |
| 71 | fun start(path: String) { |
| 72 | if (started) return |
| 73 | |
| 74 | if (!File(path).exists()) throw IllegalArgumentException(" can't find the path '${path}', typo?") |
| 75 | if (!File(path + "/simpleHead").exists()) throw IllegalArgumentException(" can't find the binary inside'${path}', is this the correct directory?") |
| 76 | |
| 77 | val b = ProcessBuilder() |
| 78 | b.command(path + "/simpleHead").redirectErrorStream(true) |
| 79 | val p = b.start() |
| 80 | val reader = p.inputStream.bufferedReader() |
| 81 | |
| 82 | head = SimpleHead() |
| 83 | |
| 84 | Thread { |
| 85 | started = true |
| 86 | |
| 87 | while (true) { |
| 88 | try { |
| 89 | val rr = reader.readLine() |
| 90 | print("r " + rr) |
| 91 | if (rr != null) |
| 92 | now = head!!.readLine(rr) |
| 93 | } catch (e: Exception) { |
| 94 | e.printStackTrace() |
| 95 | Thread.sleep(5) |
| 96 | } |
| 97 | } |
| 98 | }.start() |
| 99 | |
| 100 | } |
| 101 | |
| 102 | @JvmStatic |
nothing calls this directly
no test coverage detected