JAL-3246 JAL-3247 Reworked JVL files as getdown.txt config with limitations
[jalview.git] / getdown / src / getdown / core / src / main / java / com / threerings / getdown / data / EnvConfig.java
index 6de4e2e..57b8d84 100644 (file)
@@ -7,12 +7,15 @@ package com.threerings.getdown.data;
 
 import java.io.File;
 import java.io.FileInputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
 import java.security.cert.Certificate;
 import java.security.cert.CertificateFactory;
 import java.security.cert.X509Certificate;
 import java.util.*;
 
 import com.threerings.getdown.util.StringUtil;
+import com.threerings.getdown.data.Application;
 
 /** Configuration that comes from our "environment" (command line args, sys props, etc.). */
 public final class EnvConfig {
@@ -138,8 +141,21 @@ public final class EnvConfig {
                                     appIdProv + "'"));
             }
         }
+        
+        int skipArgs = 2;
+        // Look for locator file, pass to Application and remove from appArgs
+        String argvLocatorFilename = argv.length > 2 ? argv[2] : null;
+        if (
+                !StringUtil.isBlank(argvLocatorFilename)
+                && argvLocatorFilename.toLowerCase().endsWith("."+Application.LOCATOR_FILE_EXTENSION)
+                ) {
+          notes.add(Note.info("locatorFilename in args: '"+argv[2]+"'"));
+          Application.setLocatorFile(argvLocatorFilename);
+          
+          skipArgs++;
+        }
 
-        // ensure that we were able to fine an app dir
+        // ensure that we were able to find an app dir
         if (appDir == null) {
             return null; // caller will report problem to user
         }
@@ -171,9 +187,9 @@ public final class EnvConfig {
             return null;
         }
 
-        // pass along anything after the first two args as extra app args
-        List<String> appArgs = argv.length > 2 ?
-            Arrays.asList(argv).subList(2, argv.length) :
+        // pass along anything after the first two (or three) args as extra app args
+        List<String> appArgs = argv.length > skipArgs ?
+            Arrays.asList(argv).subList(skipArgs, argv.length) :
             Collections.<String>emptyList();
 
         // load X.509 certificate if it exists