Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions app/src/processing/app/platform/WindowsPlatform.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,29 @@ boolean register() throws UnsupportedEncodingException {
// { Base.CONTRIB_BUNDLE_EXT, "Processing Contribution Bundle" }
// };

static final String REG_APP_DIR =
System.getProperty("user.dir").replace('/', '\\');
static boolean exeFileExists(File folder) {
File exeFile = new File(folder, APP_NAME.toLowerCase() + ".exe");
return exeFile.exists();
}

static String getRegAppDir() {
try {
// Get the JAR file containing this class (WindowsPlatform)
File jarFile = new File(WindowsPlatform.class.getProtectionDomain().
getCodeSource().getLocation().toURI());
// Get the JAR folder ("app" in the standard jpackage layout)
File jarDir = jarFile.getParentFile();
// Get the processing.exe folder (parent of "app" in the standard layout)
File exeDir = jarDir.getParentFile();

if (exeFileExists(exeDir)) return exeDir.getAbsolutePath(); // standard folder layout
if (exeFileExists(jarDir)) return jarDir.getAbsolutePath(); // if exe and jar is in same folder
} catch (java.net.URISyntaxException e) {
}
return System.getProperty("user.dir"); // processing.exe not found
}

static final String REG_APP_DIR = getRegAppDir().replace('/', '\\');
static final String REG_OPEN_COMMAND =
REG_APP_DIR + "\\" + APP_NAME.toLowerCase() + ".exe \"%1\"";
static final String[] APP_SCHEMES = { "pde" }; // use pde://
Expand Down