diff options
Diffstat (limited to 'app/src/main/java/org/pacien/tincapp/commands/Executor.java')
-rw-r--r-- | app/src/main/java/org/pacien/tincapp/commands/Executor.java | 44 |
1 files changed, 0 insertions, 44 deletions
diff --git a/app/src/main/java/org/pacien/tincapp/commands/Executor.java b/app/src/main/java/org/pacien/tincapp/commands/Executor.java deleted file mode 100644 index edf229c..0000000 --- a/app/src/main/java/org/pacien/tincapp/commands/Executor.java +++ /dev/null | |||
@@ -1,44 +0,0 @@ | |||
1 | package org.pacien.tincapp.commands; | ||
2 | |||
3 | import java.io.BufferedReader; | ||
4 | import java.io.IOException; | ||
5 | import java.io.InputStreamReader; | ||
6 | import java.util.Collections; | ||
7 | import java.util.LinkedList; | ||
8 | import java.util.List; | ||
9 | |||
10 | /** | ||
11 | * @author pacien | ||
12 | */ | ||
13 | final class Executor { | ||
14 | |||
15 | private Executor() { | ||
16 | // static class | ||
17 | } | ||
18 | |||
19 | static { | ||
20 | System.loadLibrary("exec"); | ||
21 | } | ||
22 | |||
23 | /** | ||
24 | * @return -1 on error, forked child PID otherwise | ||
25 | */ | ||
26 | static private native int forkExec(String[] argcv); | ||
27 | |||
28 | static public void forkExec(Command cmd) throws IOException { | ||
29 | if (forkExec(cmd.asArray()) == -1) | ||
30 | throw new IOException(); | ||
31 | } | ||
32 | |||
33 | static public List<String> call(Command cmd) throws IOException { | ||
34 | Process proc = new ProcessBuilder(cmd.asList()).start(); | ||
35 | BufferedReader outputReader = new BufferedReader(new InputStreamReader(proc.getInputStream())); | ||
36 | |||
37 | String line; | ||
38 | List<String> list = new LinkedList<>(); | ||
39 | while ((line = outputReader.readLine()) != null) list.add(line); | ||
40 | |||
41 | return Collections.unmodifiableList(list); | ||
42 | } | ||
43 | |||
44 | } | ||