Skip to content

Commit af70053

Browse files
committed
Improved Plaftorm.openUrl(..) for Windows
If a local file is being opened, now the function tries to convert the path into a URI. This seems to be a more reliable way to open file on Windows 10 that has a more strict permission policy on cmd.exe.
1 parent b00185e commit af70053

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

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

+12
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,18 @@ public File getDefaultSketchbookFolder() throws Exception {
119119

120120
@Override
121121
public void openURL(String url) throws Exception {
122+
if (!url.startsWith("http") && !url.startsWith("file:")) {
123+
// Check if we are trying to open a local file
124+
File file = new File(url);
125+
if (file.exists()) {
126+
// in this case convert the path to a "file:" url
127+
url = file.toURI().toString();
128+
129+
// this allows to open the file on Windows 10 that
130+
// has a more strict permission policy for cmd.exe
131+
}
132+
}
133+
122134
// this is not guaranteed to work, because who knows if the
123135
// path will always be c:\progra~1 et al. also if the user has
124136
// a different browser set as their default (which would

0 commit comments

Comments
 (0)