Debian Codegraph @

arduino-core/src/processing/app/tools/DoubleQuotedArgumentsOnWindowsCommandLine.java

raw symbols SCIP
1 package processing.app.tools;
2
3 import org.apache.commons.exec.CommandLine;
4 import processing.app.helpers.OSUtils;
5
6 import java.io.File;
7
8 public class DoubleQuotedArgumentsOnWindowsCommandLine extends CommandLine {
9
10 public DoubleQuotedArgumentsOnWindowsCommandLine(String executable) {
11 super(executable);
12 }
13
14 public DoubleQuotedArgumentsOnWindowsCommandLine(File executable) {
15 super(executable);
16 }
17
18 public DoubleQuotedArgumentsOnWindowsCommandLine(CommandLine other) {
19 super(other);
20 }
21
22 @Override
23 public CommandLine addArgument(String argument, boolean handleQuoting) {
24 // Brutal hack to workaround windows command line parsing.
25 // http://stackoverflow.com/questions/5969724/java-runtime-exec-fails-to-escape-characters-properly
26 // http://msdn.microsoft.com/en-us/library/a1y7w461.aspx
27 // http://bugs.sun.com/view_bug.do?bug_id=6468220
28 // http://bugs.sun.com/view_bug.do?bug_id=6518827
29 if (argument.contains("\"") && OSUtils.isWindows()) {
30 argument = argument.replace("\"", "\\\"");
31 }
32
33 return super.addArgument(argument, handleQuoting);
34 }
35 }