|
@@ -22,11 +22,12 @@
|
22
|
22
|
|
23
|
23
|
package com.dmdirc.addons.dcc.kde;
|
24
|
24
|
|
25
|
|
-import com.dmdirc.util.io.StreamReader;
|
|
25
|
+import com.dmdirc.util.io.StreamUtils;
|
26
|
26
|
|
27
|
27
|
import java.io.File;
|
28
|
28
|
import java.io.IOException;
|
29
|
29
|
import java.util.ArrayList;
|
|
30
|
+import java.util.List;
|
30
|
31
|
|
31
|
32
|
/**
|
32
|
33
|
* Hold a Process and stream readers for a KDialog Process.
|
|
@@ -37,10 +38,10 @@ public class KDialogProcess {
|
37
|
38
|
private static final boolean IS_BIN = new File("/bin/kdialog").exists();
|
38
|
39
|
/** Does KDialog exist? */
|
39
|
40
|
private static final boolean HAS_KDIALOG = IS_BIN || new File("/usr/bin/kdialog").exists();
|
40
|
|
- /** Stream for the stdout stream for this process. */
|
41
|
|
- private final StreamReader stdOutputStream;
|
42
|
|
- /** Stream for the stderr stream for this process. */
|
43
|
|
- private final StreamReader stdErrorStream;
|
|
41
|
+ /** Output from the output stream. */
|
|
42
|
+ private final List<String> stdOutput;
|
|
43
|
+ /** Output from the error stream. */
|
|
44
|
+ private final List<String> stdError;
|
44
|
45
|
/** The actual process for this process. */
|
45
|
46
|
private final Process process;
|
46
|
47
|
|
|
@@ -56,10 +57,10 @@ public class KDialogProcess {
|
56
|
57
|
System.arraycopy(params, 0, exec, 1, params.length);
|
57
|
58
|
exec[0] = IS_BIN ? "/bin/kdialog" : "/usr/bin/kdialog";
|
58
|
59
|
process = Runtime.getRuntime().exec(exec);
|
59
|
|
- stdOutputStream = new StreamReader(process.getInputStream(), new ArrayList<String>());
|
60
|
|
- stdErrorStream = new StreamReader(process.getErrorStream(), new ArrayList<String>());
|
61
|
|
- stdOutputStream.start();
|
62
|
|
- stdErrorStream.start();
|
|
60
|
+ stdOutput = new ArrayList<>();
|
|
61
|
+ stdError = new ArrayList<>();
|
|
62
|
+ StreamUtils.readStreamIntoList(process.getInputStream(), stdOutput);
|
|
63
|
+ StreamUtils.readStreamIntoList(process.getErrorStream(), stdError);
|
63
|
64
|
}
|
64
|
65
|
|
65
|
66
|
/**
|
|
@@ -85,8 +86,8 @@ public class KDialogProcess {
|
85
|
86
|
*
|
86
|
87
|
* @return The StreamReader for this KDialogProcess's stdout stream
|
87
|
88
|
*/
|
88
|
|
- public StreamReader getStdOutStream() {
|
89
|
|
- return stdOutputStream;
|
|
89
|
+ public List<String> getStdOut() {
|
|
90
|
+ return stdOutput;
|
90
|
91
|
}
|
91
|
92
|
|
92
|
93
|
/**
|
|
@@ -94,8 +95,8 @@ public class KDialogProcess {
|
94
|
95
|
*
|
95
|
96
|
* @return The StreamReader for this KDialogProcess's stderr stream
|
96
|
97
|
*/
|
97
|
|
- public StreamReader getStdErrStream() {
|
98
|
|
- return stdErrorStream;
|
|
98
|
+ public List<String> getStdErr() {
|
|
99
|
+ return stdError;
|
99
|
100
|
}
|
100
|
101
|
|
101
|
102
|
/**
|