mirror of
https://github.com/arduino/Arduino.git
synced 2025-02-27 21:54:30 +01:00
Workaround for incorrect argument passing of Runtime.exec(args[]) method on Windows.
More info here: http://stackoverflow.com/questions/5969724/java-runtime-exec-fails-to-escape-characters-properly http://msdn.microsoft.com/en-us/library/a1y7w461.aspx http://bugs.sun.com/view_bug.do?bug_id=6468220 http://bugs.sun.com/view_bug.do?bug_id=6518827 Affects #1422
This commit is contained in:
parent
1e8e20a66b
commit
f65e736a12
@ -39,6 +39,7 @@ import processing.app.Preferences;
|
||||
import processing.app.Sketch;
|
||||
import processing.app.SketchCode;
|
||||
import processing.app.helpers.PreferencesMap;
|
||||
import processing.app.helpers.ProcessUtils;
|
||||
import processing.app.helpers.StringReplacer;
|
||||
import processing.app.helpers.filefilters.OnlyDirs;
|
||||
import processing.app.packages.Library;
|
||||
@ -343,9 +344,8 @@ public class Compiler implements MessageConsumer {
|
||||
secondErrorFound = false;
|
||||
|
||||
Process process;
|
||||
|
||||
try {
|
||||
process = Runtime.getRuntime().exec(command);
|
||||
process = ProcessUtils.exec(command);
|
||||
} catch (IOException e) {
|
||||
RunnerException re = new RunnerException(e.getMessage());
|
||||
re.hideStackTrace();
|
||||
|
@ -30,6 +30,7 @@ import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import processing.app.helpers.PreferencesMap;
|
||||
import processing.app.helpers.ProcessUtils;
|
||||
import processing.app.helpers.StringReplacer;
|
||||
|
||||
public class Sizer implements MessageConsumer {
|
||||
@ -67,7 +68,7 @@ public class Sizer implements MessageConsumer {
|
||||
textSize = -1;
|
||||
dataSize = -1;
|
||||
eepromSize = -1;
|
||||
Process process = Runtime.getRuntime().exec(cmd);
|
||||
Process process = ProcessUtils.exec(cmd);
|
||||
MessageSiphon in = new MessageSiphon(process.getInputStream(), this);
|
||||
MessageSiphon err = new MessageSiphon(process.getErrorStream(), this);
|
||||
|
||||
|
@ -36,6 +36,7 @@ import processing.app.I18n;
|
||||
import processing.app.Preferences;
|
||||
import processing.app.Serial;
|
||||
import processing.app.SerialNotFoundException;
|
||||
import processing.app.helpers.ProcessUtils;
|
||||
|
||||
public abstract class Uploader implements MessageConsumer {
|
||||
static final String BUGS_URL =
|
||||
@ -107,7 +108,7 @@ public abstract class Uploader implements MessageConsumer {
|
||||
}
|
||||
System.out.println();
|
||||
}
|
||||
Process process = Runtime.getRuntime().exec(commandArray);
|
||||
Process process = ProcessUtils.exec(commandArray);
|
||||
new MessageSiphon(process.getInputStream(), this);
|
||||
new MessageSiphon(process.getErrorStream(), this);
|
||||
|
||||
|
25
app/src/processing/app/helpers/ProcessUtils.java
Normal file
25
app/src/processing/app/helpers/ProcessUtils.java
Normal file
@ -0,0 +1,25 @@
|
||||
package processing.app.helpers;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import processing.app.Base;
|
||||
|
||||
public class ProcessUtils {
|
||||
|
||||
public static Process exec(String[] command) throws IOException {
|
||||
// No problems on linux and mac
|
||||
if (!Base.isWindows()) {
|
||||
return Runtime.getRuntime().exec(command);
|
||||
}
|
||||
|
||||
// Brutal hack to workaround windows command line parsing.
|
||||
// http://stackoverflow.com/questions/5969724/java-runtime-exec-fails-to-escape-characters-properly
|
||||
// http://msdn.microsoft.com/en-us/library/a1y7w461.aspx
|
||||
// http://bugs.sun.com/view_bug.do?bug_id=6468220
|
||||
// http://bugs.sun.com/view_bug.do?bug_id=6518827
|
||||
String[] cmdLine = new String[command.length];
|
||||
for (int i = 0; i < command.length; i++)
|
||||
cmdLine[i] = command[i].replace("\"", "\\\"");
|
||||
return Runtime.getRuntime().exec(cmdLine);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user