[izpack-changes] r1668 - in izpack-src/trunk: . src/lib/com/izforge/izpack/installer

noreply at berlios.de noreply at berlios.de
Thu Dec 21 22:03:22 CET 2006


Author: jponge
Date: 2006-12-21 22:03:18 +0100 (Thu, 21 Dec 2006)
New Revision: 1668

Modified:
   izpack-src/trunk/Versions.txt
   izpack-src/trunk/src/lib/com/izforge/izpack/installer/InstallerBase.java
Log:
Use the ProgramFiles environment variables to detect the Windows Program Files folder path. (Markus Schlegel)

Modified: izpack-src/trunk/Versions.txt
===================================================================
--- izpack-src/trunk/Versions.txt	2006-12-21 20:34:06 UTC (rev 1667)
+++ izpack-src/trunk/Versions.txt	2006-12-21 21:03:18 UTC (rev 1668)
@@ -23,6 +23,8 @@
 - Fix for calling the IzPack Ant task from Maven builds (Vladimir Ralev, JBoss/RedHat, via Julien Ponge)
 - Support for uncompressing archives and adding their content at the installer generation time (Nils Meier, via Julien Ponge)
 - Fix for default button changes when a text field receives focus in UserInputPanel (Vladimir Ralev, JBoss/RedHat, via Dennis Reil)
+- Use the 'ProgramFiles' environment variable to detect the Windows program files folder path.
+  (Markus Schlegel via Julien Ponge).
 
   > 3.9.0 (build 2006.09.25)
 - Fix NullPointerException in CompilerConfig, if you specify a 

Modified: izpack-src/trunk/src/lib/com/izforge/izpack/installer/InstallerBase.java
===================================================================
--- izpack-src/trunk/src/lib/com/izforge/izpack/installer/InstallerBase.java	2006-12-21 20:34:06 UTC (rev 1667)
+++ izpack-src/trunk/src/lib/com/izforge/izpack/installer/InstallerBase.java	2006-12-21 21:03:18 UTC (rev 1668)
@@ -241,12 +241,33 @@
     }
 
     /**
-     * Builds the default path for Windows (i.e Program Files/...).
-     * 
-     * @return The Windows default installation path.
+     * Get the default path for Windows (i.e Program Files/...).
+     * Windows has a Setting for this in the environment and in the registry.
+     * Just try to use the setting in the environment. If it fails for whatever reason, we take the former solution (buildWindowsDefaultPathFromProps).
+     * @return The Windows default installation path for applications.
      */
     private String buildWindowsDefaultPath()
     {
+      try{
+        //get value from environment...
+        String prgFilesPath = IoHelper.getenv("ProgramFiles");
+        if (prgFilesPath!=null && prgFilesPath.length()>0){
+          return prgFilesPath;
+        }else{
+          return buildWindowsDefaultPathFromProps();
+        }
+      }catch(Exception x){
+        x.printStackTrace();
+        return buildWindowsDefaultPathFromProps();
+      }
+    }
+    /** 
+     * just plain wrong in case the programfiles are not stored where the developer expects them.
+     * E.g. in custom installations of large companies or if used internationalized version of windows with a language pack.
+     * @return
+     */
+    private String buildWindowsDefaultPathFromProps()
+    {
         StringBuffer dpath = new StringBuffer("");
         try
         {




More information about the izpack-changes mailing list