From 6c59314348779660fd2aa95658f999c2676dea29 Mon Sep 17 00:00:00 2001 From: Ben Soares Date: Sat, 4 May 2019 00:03:55 +0100 Subject: [PATCH] JAL-3247 First attempt at getdown code to add macOS startup filenames to the appargs as -open filename --- .../com/threerings/getdown/data/Application.java | 11 +++++++ .../com/threerings/getdown/launcher/Getdown.java | 31 ++++++++++++++++++++ .../threerings/getdown/launcher/GetdownApp.java | 10 +++++-- 3 files changed, 50 insertions(+), 2 deletions(-) diff --git a/getdown/src/getdown/core/src/main/java/com/threerings/getdown/data/Application.java b/getdown/src/getdown/core/src/main/java/com/threerings/getdown/data/Application.java index 0a49739..212e948 100644 --- a/getdown/src/getdown/core/src/main/java/com/threerings/getdown/data/Application.java +++ b/getdown/src/getdown/core/src/main/java/com/threerings/getdown/data/Application.java @@ -767,6 +767,12 @@ public class Application // add the launch specific application arguments _appargs.addAll(_envc.appArgs); + + // add startupFiles + for (File f : startupFiles) { + _appargs.add("-open"); + _appargs.add(f.getAbsolutePath()); + } // look for custom arguments fillAssignmentListFromPairs("extra.txt", _txtJvmArgs); @@ -1760,6 +1766,10 @@ public class Application { return new File(appdir, path); } + + public void addStartupFile (File f) { + startupFiles.add(f); + } protected final EnvConfig _envc; protected File _config; @@ -1804,6 +1814,7 @@ public class Application protected List _jvmargs = new ArrayList<>(); protected List _appargs = new ArrayList<>(); + protected List startupFiles = new ArrayList<>(); protected String[] _optimumJvmArgs; diff --git a/getdown/src/getdown/launcher/src/main/java/com/threerings/getdown/launcher/Getdown.java b/getdown/src/getdown/launcher/src/main/java/com/threerings/getdown/launcher/Getdown.java index 99def4f..ae679e2 100644 --- a/getdown/src/getdown/launcher/src/main/java/com/threerings/getdown/launcher/Getdown.java +++ b/getdown/src/getdown/launcher/src/main/java/com/threerings/getdown/launcher/Getdown.java @@ -1035,6 +1035,37 @@ public abstract class Getdown extends Thread } }; + public void setStartupFilesFromParameterString(String p) { + String q = "\""; + if (p != null && p.length() > 0) { + String[] filenames; + if (p.startsWith(q) && p.endsWith(q)) { + filenames = p.substring(1,p.length()-1).split("\" \""); + } else { + filenames = new String[]{p}; + } + for (int i = 0; i < filenames.length; i++) { + String filename = filenames[i]; + String ext = null; + int j = filename.lastIndexOf('.'); + if (j > -1) { + ext = filename.substring(j+1); + } + // jvp files + if (ext.equals("jvp")) { + File f = new File(filename); + if (f.exists()) { + _app.addStartupFile(f); + } + } + // jvl files + if (ext.equals("jvl")) { + // Do stuff with the appbase here! + } + } + } + } + protected Application _app; protected Application.UpdateInterface _ifc = new Application.UpdateInterface(Config.EMPTY); diff --git a/getdown/src/getdown/launcher/src/main/java/com/threerings/getdown/launcher/GetdownApp.java b/getdown/src/getdown/launcher/src/main/java/com/threerings/getdown/launcher/GetdownApp.java index 0c8cac5..f632b65 100644 --- a/getdown/src/getdown/launcher/src/main/java/com/threerings/getdown/launcher/GetdownApp.java +++ b/getdown/src/getdown/launcher/src/main/java/com/threerings/getdown/launcher/GetdownApp.java @@ -108,7 +108,7 @@ public class GetdownApp e.printStackTrace(); } - Thread.sleep(500); + //Thread.sleep(200); // record a few things for posterity log.info("------------------ VM Info ------------------"); @@ -120,7 +120,6 @@ public class GetdownApp log.info("-- User Name: " + System.getProperty("user.name")); log.info("-- User Home: " + System.getProperty("user.home")); log.info("-- Cur dir: " + System.getProperty("user.dir")); - log.info("-- JVL: " + System.getProperty("jvl")); log.info("-- startupFilesParameterString: " + startupFilesParameterString); log.info("---------------------------------------------"); @@ -270,6 +269,9 @@ public class GetdownApp protected JFrame _frame; }; + if (getStartupFilesParameterString() != null) { + app.setStartupFilesFromParameterString(getStartupFilesParameterString()); + } app.start(); return app; } @@ -277,4 +279,8 @@ public class GetdownApp public static void setStartupFilesParameterString(String parameters) { startupFilesParameterString = parameters; } + + public static String getStartupFilesParameterString() { + return startupFilesParameterString; + } } -- 1.7.10.2