Debian Codegraph @

arduino-core/src/processing/app/helpers/ProcessUtils.java

raw symbols SCIP
1 package processing.app.helpers;
2
3 import java.io.IOException;
4 import java.util.Map;
5
6 public class ProcessUtils {
7
8 public static Process exec(String[] command) throws IOException {
9 // No problems on linux and mac
10 if (!OSUtils.isWindows()) {
11 return Runtime.getRuntime().exec(command);
12 }
13
14 // Brutal hack to workaround windows command line parsing.
15 // http://stackoverflow.com/questions/5969724/java-runtime-exec-fails-to-escape-characters-properly
16 // http://msdn.microsoft.com/en-us/library/a1y7w461.aspx
17 // http://bugs.sun.com/view_bug.do?bug_id=6468220
18 // http://bugs.sun.com/view_bug.do?bug_id=6518827
19 String[] cmdLine = new String[command.length];
20 for (int i = 0; i < command.length; i++)
21 cmdLine[i] = command[i].replace("\"", "\\\"");
22
23 ProcessBuilder pb = new ProcessBuilder(cmdLine);
24 Map<String, String> env = pb.environment();
25 env.put("CYGWIN", "nodosfilewarning");
26 return pb.start();
27 }
28 }