Skip to content

Commit 98eb1a9

Browse files
author
Federico Fissore
committed
Re-introducing JNA, used only on Windows and only to access Windows Registry. Should fix #3360
1 parent 7d8d078 commit 98eb1a9

File tree

5 files changed

+8
-12
lines changed

5 files changed

+8
-12
lines changed

arduino-core/lib/jna-4.1.0.jar

893 KB
Binary file not shown.
1.4 MB
Binary file not shown.

arduino-core/src/processing/app/windows/Platform.java

+4-12
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222

2323
package processing.app.windows;
2424

25+
import com.sun.jna.platform.win32.Advapi32Util;
26+
import com.sun.jna.platform.win32.WinReg;
2527
import org.apache.commons.exec.CommandLine;
2628
import org.apache.commons.exec.DefaultExecutor;
2729
import org.apache.commons.exec.Executor;
@@ -52,25 +54,15 @@ public void init() throws IOException {
5254
}
5355

5456
private void recoverSettingsFolderPath() throws IOException {
55-
String path = getFolderPathFromRegistry("AppData");
57+
String path = Advapi32Util.registryGetStringValue(WinReg.HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders", "AppData");
5658
this.settingsFolder = new File(path, "Arduino15");
5759
}
5860

5961
private void recoverDefaultSketchbookFolder() throws IOException {
60-
String path = getFolderPathFromRegistry("Personal");
62+
String path = Advapi32Util.registryGetStringValue(WinReg.HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders", "Personal");
6163
this.defaultSketchbookFolder = new File(path, "Arduino");
6264
}
6365

64-
private String getFolderPathFromRegistry(String folderType) throws IOException {
65-
ByteArrayOutputStream baos = new ByteArrayOutputStream();
66-
Executor executor = new DefaultExecutor();
67-
executor.setStreamHandler(new PumpStreamHandler(baos, null));
68-
69-
CommandLine toDevicePath = CommandLine.parse("reg query \"HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders\" /v \"" + folderType + "\"");
70-
executor.execute(toDevicePath);
71-
return new RegQueryParser(new String(baos.toByteArray())).getValueOfKey();
72-
}
73-
7466
/**
7567
* Remove extra quotes, slashes, and garbage from the Windows PATH.
7668
*/

build/windows/launcher/config.xml

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
<cp>lib/jackson-module-mrbean-2.2.3.jar</cp>
2929
<cp>lib/java-semver-0.8.0.jar</cp>
3030
<cp>lib/jmdns-3.4.1.jar</cp>
31+
<cp>lib/jna-4.1.0.jar</cp>
32+
<cp>lib/jna-platform-4.1.0.jar</cp>
3133
<cp>lib/jsch-0.1.50.jar</cp>
3234
<cp>lib/jssc-2.8.0.jar</cp>
3335
<cp>lib/pde.jar</cp>

build/windows/launcher/config_debug.xml

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
<cp>lib/jackson-module-mrbean-2.2.3.jar</cp>
2929
<cp>lib/java-semver-0.8.0.jar</cp>
3030
<cp>lib/jmdns-3.4.1.jar</cp>
31+
<cp>lib/jna-4.1.0.jar</cp>
32+
<cp>lib/jna-platform-4.1.0.jar</cp>
3133
<cp>lib/jsch-0.1.50.jar</cp>
3234
<cp>lib/jssc-2.8.0.jar</cp>
3335
<cp>lib/pde.jar</cp>

0 commit comments

Comments
 (0)