Skip to content

Commit 42ef9a8

Browse files
authored
Merge pull request #10 from facchinm/ide_1.6.12
Fix getBuildFolderPath method for IDE 1.6.12
2 parents a7a8ab4 + cca0712 commit 42ef9a8

File tree

1 file changed

+38
-27
lines changed

1 file changed

+38
-27
lines changed

src/EspExceptionDecoder.java

Lines changed: 38 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
import processing.app.Platform;
4040
import processing.app.PreferencesData;
4141
import processing.app.Sketch;
42-
import processing.app.SketchData;
42+
//import processing.app.SketchData;
4343
import processing.app.debug.TargetPlatform;
4444
import processing.app.helpers.FileUtils;
4545
import processing.app.helpers.ProcessUtils;
@@ -121,32 +121,43 @@ public void run() {
121121
}
122122

123123
private String getBuildFolderPath(Sketch s) {
124-
try {
125-
File buildFolder = FileUtils.createTempFolder("build", DigestUtils.md5Hex(s.getMainFilePath()) + ".tmp");
126-
//DeleteFilesOnShutdown.add(buildFolder);
127-
return buildFolder.getAbsolutePath();
128-
}
129-
catch (IOException e) {
130-
editor.statusError(e);
131-
}
132-
catch (NoSuchMethodError e) {
133-
// Arduino 1.6.5 doesn't have FileUtils.createTempFolder
134-
// String buildPath = BaseNoGui.getBuildFolder().getAbsolutePath();
135-
java.lang.reflect.Method method;
136-
try {
137-
method = BaseNoGui.class.getMethod("getBuildFolder");
138-
File f = (File) method.invoke(null);
139-
return f.getAbsolutePath();
140-
} catch (SecurityException ex) {
141-
editor.statusError(ex);
142-
} catch (IllegalAccessException ex) {
143-
editor.statusError(ex);
144-
} catch (InvocationTargetException ex) {
145-
editor.statusError(ex);
146-
} catch (NoSuchMethodException ex) {
147-
editor.statusError(ex);
148-
}
149-
}
124+
// first of all try the getBuildPath() function introduced with IDE 1.6.12
125+
// see commit arduino/Arduino#fd1541eb47d589f9b9ea7e558018a8cf49bb6d03
126+
try {
127+
String buildpath = s.getBuildPath().getAbsolutePath();
128+
return buildpath;
129+
}
130+
catch (IOException er) {
131+
editor.statusError(er);
132+
}
133+
catch (NoSuchMethodError er) {
134+
try {
135+
File buildFolder = FileUtils.createTempFolder("build", DigestUtils.md5Hex(s.getMainFilePath()) + ".tmp");
136+
//DeleteFilesOnShutdown.add(buildFolder);
137+
return buildFolder.getAbsolutePath();
138+
}
139+
catch (IOException e) {
140+
editor.statusError(e);
141+
}
142+
catch (NoSuchMethodError e) {
143+
// Arduino 1.6.5 doesn't have FileUtils.createTempFolder
144+
// String buildPath = BaseNoGui.getBuildFolder().getAbsolutePath();
145+
java.lang.reflect.Method method;
146+
try {
147+
method = BaseNoGui.class.getMethod("getBuildFolder");
148+
File f = (File) method.invoke(null);
149+
return f.getAbsolutePath();
150+
} catch (SecurityException ex) {
151+
editor.statusError(ex);
152+
} catch (IllegalAccessException ex) {
153+
editor.statusError(ex);
154+
} catch (InvocationTargetException ex) {
155+
editor.statusError(ex);
156+
} catch (NoSuchMethodException ex) {
157+
editor.statusError(ex);
158+
}
159+
}
160+
}
150161
return "";
151162
}
152163

0 commit comments

Comments
 (0)