]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.excel/src/org/simantics/excel/ExecEnvironment.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.excel / src / org / simantics / excel / ExecEnvironment.java
1 package org.simantics.excel;
2
3 public class ExecEnvironment {
4
5     public enum OSType {
6         APPLE, LINUX, SUN, WINDOWS, UNKNOWN
7     }
8     
9     public enum ARCHType {
10         PPC, PPC_64, SPARC, X86, X86_64, UNKNOWN;
11     }
12     
13     public final OSType os;
14     public final ARCHType arch;
15
16     private ExecEnvironment(OSType os, ARCHType arch) {
17         this.os = os;
18         this.arch = arch;
19     }
20
21     public static ExecEnvironment calculate() {
22         return new ExecEnvironment(calculateOS(), calculateArch());
23     }
24
25     public static ARCHType calculateArch() {
26         String osArch = System.getProperty("os.arch", "");
27         osArch = osArch.toLowerCase();
28         if (osArch.equals("i386") || osArch.equals("i586") || osArch.equals("i686") || osArch.equals("x86"))
29             return ARCHType.X86;
30         if (osArch.startsWith("amd64") || osArch.startsWith("x86_64"))
31             return ARCHType.X86_64;
32         if (osArch.equals("ppc"))
33             return ARCHType.PPC;
34         if (osArch.startsWith("ppc"))
35             return ARCHType.PPC_64;
36         if (osArch.startsWith("sparc"))
37             return ARCHType.SPARC;
38         return ARCHType.UNKNOWN;
39     }
40
41     public static OSType calculateOS() {
42         String osName = System.getProperty("os.name", "");
43         osName = osName.toLowerCase();
44         if (osName.startsWith("mac os x"))
45             return OSType.APPLE;
46         if (osName.startsWith("windows"))
47             return OSType.WINDOWS;
48         if (osName.startsWith("linux"))
49             return OSType.LINUX;
50         if (osName.startsWith("sun"))
51             return OSType.SUN;
52         return OSType.UNKNOWN;
53     }
54 }