1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-01-19 08:52:15 +01:00

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.
This commit is contained in:
Cristian Maglie 2016-11-03 19:37:52 +02:00
parent b00185e63d
commit af70053218

View File

@ -119,6 +119,18 @@ public class Platform extends processing.app.Platform {
@Override
public void openURL(String url) throws Exception {
if (!url.startsWith("http") && !url.startsWith("file:")) {
// Check if we are trying to open a local file
File file = new File(url);
if (file.exists()) {
// in this case convert the path to a "file:" url
url = file.toURI().toString();
// this allows to open the file on Windows 10 that
// has a more strict permission policy for cmd.exe
}
}
// this is not guaranteed to work, because who knows if the
// path will always be c:\progra~1 et al. also if the user has
// a different browser set as their default (which would