changeset 1503:19467a2f1f25

PR3645, second part - following windows system paths correctly * netx/net/sourceforge/jnlp/config/PathsAndFiles.java: following https://docs.oracle.com/javase/7/docs/technotes/guides/jweb/jcp/properties.html (SystemCofigFileDescriptor) now honor WINDIR on windows
author Jiri Vanek <jvanek@redhat.com>
date Tue, 18 Dec 2018 11:16:10 +0100
parents dfc800562a29
children fa507388eea5
files ChangeLog netx/net/sourceforge/jnlp/config/PathsAndFiles.java
diffstat 2 files changed, 26 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Tue Dec 18 11:15:38 2018 +0100
+++ b/ChangeLog	Tue Dec 18 11:16:10 2018 +0100
@@ -1,3 +1,10 @@
+2018-11-27  Jiri Vanek <jvanek@redhat.com>
+
+	PR3645, second part - following windows system paths correctly
+	* netx/net/sourceforge/jnlp/config/PathsAndFiles.java: following 
+	https://docs.oracle.com/javase/7/docs/technotes/guides/jweb/jcp/properties.html
+	(SystemCofigFileDescriptor) now honor WINDIR on windows
+
 2018-11-27  Jiri Vanek <jvanek@redhat.com>
             Lars Herschke <lhersch@dssgmbh.de>
 
--- a/netx/net/sourceforge/jnlp/config/PathsAndFiles.java	Tue Dec 18 11:15:38 2018 +0100
+++ b/netx/net/sourceforge/jnlp/config/PathsAndFiles.java	Tue Dec 18 11:16:10 2018 +0100
@@ -62,6 +62,7 @@
     public static final String XDG_CACHE_HOME_VAR = "XDG_CACHE_HOME";
     public static final String XDG_RUNTIME_DIR_VAR = "XDG_RUNTIME_DIR";
     private static final String XDG_DATA_HOME = "XDG_DATA_HOME";
+    private static final String WINDIR = "WINDIR";
     private static final String TMP_PROP = "java.io.tmpdir";
     private static final String HOME_PROP = "user.home";
     private static final String JAVA_PROP = "java.home";
@@ -362,8 +363,25 @@
 
     private static class SystemCofigFileDescriptor extends InfrastructureFileDescriptor {
 
+        private static final String windowsPathSuffix = File.separator + "Sun" + File.separator + "Java";
+        private static final String unixPathSuffix = File.separator + "etc" + File.separator + ".java";
+
+        private static String getSystemConfigDir() {
+            if (JNLPRuntime.isWindows()) {
+                return System.getenv(WINDIR) + windowsPathSuffix;
+            } else {
+                return unixPathSuffix;
+            }
+        }
+
+        @Override
+        public String getSystemPathStubAcronym() {
+            //note the hardcoded % instead of VARIABLE (actuall leading to idea, that docs, when generated on windows may not make sense)
+            return "{" + "%" + WINDIR + windowsPathSuffix + " or " + unixPathSuffix + "}";
+        }
+
         private SystemCofigFileDescriptor(String fileName, String pathSub, String description, Target... target) {
-            super(fileName, pathSub, File.separator + "etc" + File.separator + ".java", description, target);
+            super(fileName, pathSub, getSystemConfigDir(), description, target);
         }
 
     }