File tree 4 files changed +31
-4
lines changed 4 files changed +31
-4
lines changed Original file line number Diff line number Diff line change 39
39
import processing .app .Sketch ;
40
40
import processing .app .SketchCode ;
41
41
import processing .app .helpers .PreferencesMap ;
42
+ import processing .app .helpers .ProcessUtils ;
42
43
import processing .app .helpers .StringReplacer ;
43
44
import processing .app .helpers .filefilters .OnlyDirs ;
44
45
import processing .app .packages .Library ;
@@ -343,9 +344,8 @@ private void execAsynchronously(String[] command) throws RunnerException {
343
344
secondErrorFound = false ;
344
345
345
346
Process process ;
346
-
347
347
try {
348
- process = Runtime . getRuntime () .exec (command );
348
+ process = ProcessUtils .exec (command );
349
349
} catch (IOException e ) {
350
350
RunnerException re = new RunnerException (e .getMessage ());
351
351
re .hideStackTrace ();
Original file line number Diff line number Diff line change 30
30
import java .util .regex .Pattern ;
31
31
32
32
import processing .app .helpers .PreferencesMap ;
33
+ import processing .app .helpers .ProcessUtils ;
33
34
import processing .app .helpers .StringReplacer ;
34
35
35
36
public class Sizer implements MessageConsumer {
@@ -67,7 +68,7 @@ public long[] computeSize() throws RunnerException {
67
68
textSize = -1 ;
68
69
dataSize = -1 ;
69
70
eepromSize = -1 ;
70
- Process process = Runtime . getRuntime () .exec (cmd );
71
+ Process process = ProcessUtils .exec (cmd );
71
72
MessageSiphon in = new MessageSiphon (process .getInputStream (), this );
72
73
MessageSiphon err = new MessageSiphon (process .getErrorStream (), this );
73
74
Original file line number Diff line number Diff line change 36
36
import processing .app .Preferences ;
37
37
import processing .app .Serial ;
38
38
import processing .app .SerialNotFoundException ;
39
+ import processing .app .helpers .ProcessUtils ;
39
40
40
41
public abstract class Uploader implements MessageConsumer {
41
42
static final String BUGS_URL =
@@ -107,7 +108,7 @@ protected boolean executeUploadCommand(String commandArray[])
107
108
}
108
109
System .out .println ();
109
110
}
110
- Process process = Runtime . getRuntime () .exec (commandArray );
111
+ Process process = ProcessUtils .exec (commandArray );
111
112
new MessageSiphon (process .getInputStream (), this );
112
113
new MessageSiphon (process .getErrorStream (), this );
113
114
Original file line number Diff line number Diff line change
1
+ package processing .app .helpers ;
2
+
3
+ import java .io .IOException ;
4
+
5
+ import processing .app .Base ;
6
+
7
+ public class ProcessUtils {
8
+
9
+ public static Process exec (String [] command ) throws IOException {
10
+ // No problems on linux and mac
11
+ if (!Base .isWindows ()) {
12
+ return Runtime .getRuntime ().exec (command );
13
+ }
14
+
15
+ // Brutal hack to workaround windows command line parsing.
16
+ // http://stackoverflow.com/questions/5969724/java-runtime-exec-fails-to-escape-characters-properly
17
+ // http://msdn.microsoft.com/en-us/library/a1y7w461.aspx
18
+ // http://bugs.sun.com/view_bug.do?bug_id=6468220
19
+ // http://bugs.sun.com/view_bug.do?bug_id=6518827
20
+ String [] cmdLine = new String [command .length ];
21
+ for (int i = 0 ; i < command .length ; i ++)
22
+ cmdLine [i ] = command [i ].replace ("\" " , "\\ \" " );
23
+ return Runtime .getRuntime ().exec (cmdLine );
24
+ }
25
+ }
You can’t perform that action at this time.
0 commit comments