home *** CD-ROM | disk | FTP | other *** search
- package java.lang;
-
- import java.io.File;
- import java.io.IOException;
- import java.util.ArrayList;
- import java.util.List;
- import java.util.Map;
-
- public final class ProcessBuilder {
- private List<String> command;
- private File directory;
- private Map<String, String> environment;
- private boolean redirectErrorStream;
-
- public ProcessBuilder(List<String> var1) {
- if (var1 == null) {
- throw new NullPointerException();
- } else {
- this.command = var1;
- }
- }
-
- public ProcessBuilder(String... var1) {
- this.command = new ArrayList(var1.length);
-
- for(String var5 : var1) {
- this.command.add(var5);
- }
-
- }
-
- public ProcessBuilder command(List<String> var1) {
- if (var1 == null) {
- throw new NullPointerException();
- } else {
- this.command = var1;
- return this;
- }
- }
-
- public ProcessBuilder command(String... var1) {
- this.command = new ArrayList(var1.length);
-
- for(String var5 : var1) {
- this.command.add(var5);
- }
-
- return this;
- }
-
- public List<String> command() {
- return this.command;
- }
-
- public Map<String, String> environment() {
- SecurityManager var1 = System.getSecurityManager();
- if (var1 != null) {
- var1.checkPermission(new RuntimePermission("getenv.*"));
- }
-
- if (this.environment == null) {
- this.environment = ProcessEnvironment.environment();
- }
-
- assert this.environment != null;
-
- return this.environment;
- }
-
- ProcessBuilder environment(String[] var1) {
- assert this.environment == null;
-
- if (var1 != null) {
- this.environment = ProcessEnvironment.emptyEnvironment(var1.length);
-
- assert this.environment != null;
-
- for(String var5 : var1) {
- if (var5.indexOf(0) != -1) {
- var5 = var5.replaceFirst("\u0000.*", "");
- }
-
- int var6 = var5.indexOf(61, 1);
- if (var6 != -1) {
- this.environment.put(var5.substring(0, var6), var5.substring(var6 + 1));
- }
- }
- }
-
- return this;
- }
-
- public File directory() {
- return this.directory;
- }
-
- public ProcessBuilder directory(File var1) {
- this.directory = var1;
- return this;
- }
-
- public boolean redirectErrorStream() {
- return this.redirectErrorStream;
- }
-
- public ProcessBuilder redirectErrorStream(boolean var1) {
- this.redirectErrorStream = var1;
- return this;
- }
-
- public Process start() throws IOException {
- String[] var1 = (String[])this.command.toArray(new String[this.command.size()]);
-
- for(String var5 : var1) {
- if (var5 == null) {
- throw new NullPointerException();
- }
- }
-
- String var7 = var1[0];
- SecurityManager var8 = System.getSecurityManager();
- if (var8 != null) {
- var8.checkExec(var7);
- }
-
- String var9 = this.directory == null ? null : this.directory.toString();
-
- try {
- return ProcessImpl.start(var1, this.environment, var9, this.redirectErrorStream);
- } catch (IOException var6) {
- throw new IOException("Cannot run program \"" + var7 + "\"" + (var9 == null ? "" : " (in directory \"" + var9 + "\")") + ": " + var6.getMessage(), var6);
- }
- }
- }
-