From 4bf5ac093cef7deec70ad36dc99d0e7a664bb278 Mon Sep 17 00:00:00 2001
From: brinn <brinn>
Date: Fri, 18 Jul 2008 19:20:22 +0000
Subject: [PATCH] add: method OSUtilities.getCompatibleComputerPlatform() use:
 OSUtilities.getCompatibleComputerPlatform in
 FileUtilties.tryCopyNativeLibraryToTempFile()

SVN: 7322
---
 .../cisd/common/utilities/FileUtilities.java  |  2 +-
 .../cisd/common/utilities/OSUtilities.java    | 31 ++++++++++++++-----
 2 files changed, 24 insertions(+), 9 deletions(-)

diff --git a/common/source/java/ch/systemsx/cisd/common/utilities/FileUtilities.java b/common/source/java/ch/systemsx/cisd/common/utilities/FileUtilities.java
index 6abc120ac86..c6dd265ab01 100644
--- a/common/source/java/ch/systemsx/cisd/common/utilities/FileUtilities.java
+++ b/common/source/java/ch/systemsx/cisd/common/utilities/FileUtilities.java
@@ -1126,7 +1126,7 @@ public final class FileUtilities
     public final static String tryCopyNativeLibraryToTempFile(final String libraryName)
     {
         return tryCopyResourceToTempFile(String.format("/native/%s/%s/%s.so", libraryName,
-                OSUtilities.getComputerPlatform(), libraryName), libraryName, ".so");
+                OSUtilities.getCompatibleComputerPlatform(), libraryName), libraryName, ".so");
     }
 
     /**
diff --git a/common/source/java/ch/systemsx/cisd/common/utilities/OSUtilities.java b/common/source/java/ch/systemsx/cisd/common/utilities/OSUtilities.java
index 5aabae64c70..a11677ee0e7 100644
--- a/common/source/java/ch/systemsx/cisd/common/utilities/OSUtilities.java
+++ b/common/source/java/ch/systemsx/cisd/common/utilities/OSUtilities.java
@@ -26,8 +26,8 @@ import java.util.regex.Pattern;
  * Some useful methods related to the operating system.
  * <p>
  * Does <em>not</em> depend on any library jar files. But before using or extending this class and
- * if you do not mind using <a href="http://jakarta.apache.org/commons/lang/">commons lang</a>,
- * then have a look on <code>SystemUtils</code>.
+ * if you do not mind using <a href="http://jakarta.apache.org/commons/lang/">commons lang</a>, then
+ * have a look on <code>SystemUtils</code>.
  * </p>
  * 
  * @author Bernd Rinn
@@ -62,6 +62,21 @@ public class OSUtilities
         return System.getProperty("java.vendor").startsWith("Apple");
     }
 
+    /**
+     * @return The name of the computer platform that is compatible with respect to executables (CPU
+     *         architecture and OS name, both as precise as possible to be able to share libraries
+     *         and binaries).
+     */
+    public static String getCompatibleComputerPlatform()
+    {
+        String osName = System.getProperty("os.name");
+        if ("Windows XP".equals(osName) || "Windows Vista".equals(osName))
+        {
+            osName = "Windows";
+        }
+        return System.getProperty("os.arch") + "-" + osName;
+    }
+
     /**
      * @return The name of the computer platform (CPU architecture and OS name).
      */
@@ -79,8 +94,8 @@ public class OSUtilities
     }
 
     /**
-     * @return <code>true</code> if the user that runs this program is known to have root
-     *         privileges (based on his name).
+     * @return <code>true</code> if the user that runs this program is known to have root privileges
+     *         (based on his name).
      */
     public static boolean isRoot()
     {
@@ -156,8 +171,8 @@ public class OSUtilities
      * @param executableName The name of the executable to search for. Under Windows, a name with
      *            and without <code>.exe</code> appended will work, but the executable found needs
      *            to have the .exe extension.
-     * @return The binary file that has been found in the path, or <code>null</code>, if no
-     *         binary file could be found.
+     * @return The binary file that has been found in the path, or <code>null</code>, if no binary
+     *         file could be found.
      */
     public static File findExecutable(String executableName)
     {
@@ -174,8 +189,8 @@ public class OSUtilities
      * @param pathSet The set of paths to search for. It is recommended to use an ordered set like
      *            the {@link LinkedHashSet} here in order to get results that are independent of the
      *            JRE implementation.
-     * @return The binary file that has been found in the path, or <code>null</code>, if no
-     *         binary file could be found.
+     * @return The binary file that has been found in the path, or <code>null</code>, if no binary
+     *         file could be found.
      */
     public static File findExecutable(String executableName, Set<String> pathSet)
     {
-- 
GitLab