Refactored OsType -> OSType

This commit is contained in:
nathan 2017-07-23 11:30:52 +02:00
parent 96724bb0e9
commit adbd14eaee
2 changed files with 47 additions and 47 deletions

View File

@ -42,7 +42,7 @@ class OS {
public static final int javaVersion = _getJavaVersion(); public static final int javaVersion = _getJavaVersion();
private static final OsType osType; private static final OSType osType;
private static final String originalTimeZone = TimeZone.getDefault() private static final String originalTimeZone = TimeZone.getDefault()
.getID(); .getID();
@ -89,31 +89,31 @@ class OS {
// android check from https://stackoverflow.com/questions/14859954/android-os-arch-output-for-arm-mips-x86 // android check from https://stackoverflow.com/questions/14859954/android-os-arch-output-for-arm-mips-x86
if (osArch.equals("armeabi")) { if (osArch.equals("armeabi")) {
// really old/low-end non-hf 32bit cpu // really old/low-end non-hf 32bit cpu
osType = OsType.AndroidArm56; osType = OSType.AndroidArm56;
} }
else if (osArch.equals("armeabi-v7a")) { else if (osArch.equals("armeabi-v7a")) {
// 32bit hf cpu // 32bit hf cpu
osType = OsType.AndroidArm7; osType = OSType.AndroidArm7;
} }
else if (osArch.equals("arm64-v8a")) { else if (osArch.equals("arm64-v8a")) {
// 64bit hf cpu // 64bit hf cpu
osType = OsType.AndroidArm8; osType = OSType.AndroidArm8;
} }
else if (osArch.equals("x86")) { else if (osArch.equals("x86")) {
// 32bit x86 (usually emulator) // 32bit x86 (usually emulator)
osType = OsType.AndroidX86; osType = OSType.AndroidX86;
} }
else if (osArch.equals("x86_64")) { else if (osArch.equals("x86_64")) {
// 64bit x86 (usually emulator) // 64bit x86 (usually emulator)
osType = OsType.AndroidX86_64; osType = OSType.AndroidX86_64;
} }
else if (osArch.equals("mips")) { else if (osArch.equals("mips")) {
// 32bit mips // 32bit mips
osType = OsType.AndroidMips; osType = OSType.AndroidMips;
} }
else if (osArch.equals("mips64")) { else if (osArch.equals("mips64")) {
// 64bit mips // 64bit mips
osType = OsType.AndroidMips64; osType = OSType.AndroidMips64;
} else { } else {
// who knows? // who knows?
osType = null; osType = null;
@ -122,52 +122,52 @@ class OS {
else { else {
// normal linux 32/64/arm32/arm64 // normal linux 32/64/arm32/arm64
if ("amd64".equals(osArch)) { if ("amd64".equals(osArch)) {
osType = OsType.Linux64; osType = OSType.Linux64;
} }
else { else {
if (osArch.startsWith("arm")) { if (osArch.startsWith("arm")) {
if (osArch.contains("v8")) { if (osArch.contains("v8")) {
osType = OsType.LinuxArm64; osType = OSType.LinuxArm64;
} }
else { else {
osType = OsType.LinuxArm32; osType = OSType.LinuxArm32;
} }
} }
else { else {
osType = OsType.Linux32; osType = OSType.Linux32;
} }
} }
} }
} }
else if (osName.startsWith("windows")) { else if (osName.startsWith("windows")) {
if ("amd64".equals(osArch)) { if ("amd64".equals(osArch)) {
osType = OsType.Windows64; osType = OSType.Windows64;
} }
else { else {
osType = OsType.Windows32; osType = OSType.Windows32;
} }
} }
else if (osName.startsWith("mac") || osName.startsWith("darwin")) { else if (osName.startsWith("mac") || osName.startsWith("darwin")) {
if ("x86_64".equals(osArch)) { if ("x86_64".equals(osArch)) {
osType = OsType.MacOsX64; osType = OSType.MacOsX64;
} }
else { else {
osType = OsType.MacOsX32; osType = OSType.MacOsX32;
} }
} }
else if (osName.startsWith("freebsd") || osName.contains("nix") || osName.contains("nux") || osName.startsWith("aix")) { else if (osName.startsWith("freebsd") || osName.contains("nix") || osName.contains("nux") || osName.startsWith("aix")) {
if ("x86".equals(osArch) || "i386".equals(osArch)) { if ("x86".equals(osArch) || "i386".equals(osArch)) {
osType = OsType.Unix32; osType = OSType.Unix32;
} }
else if ("arm".equals(osArch)) { else if ("arm".equals(osArch)) {
osType = OsType.UnixArm; osType = OSType.UnixArm;
} }
else { else {
osType = OsType.Unix64; osType = OSType.Unix64;
} }
} }
else if (osName.startsWith("solaris") || osName.startsWith("sunos")) { else if (osName.startsWith("solaris") || osName.startsWith("sunos")) {
osType = OsType.Solaris; osType = OSType.Solaris;
} }
else { else {
osType = null; osType = null;
@ -179,7 +179,7 @@ class OS {
} }
public static public static
OsType get() { OSType get() {
return osType; return osType;
} }

View File

@ -15,7 +15,7 @@
*/ */
package dorkbox.util; package dorkbox.util;
public enum OsType { public enum OSType {
Windows32("windows_32", ".dll"), Windows32("windows_32", ".dll"),
Windows64("windows_64", ".dll"), Windows64("windows_64", ".dll"),
Linux32("linux_32", ".so"), Linux32("linux_32", ".so"),
@ -50,7 +50,7 @@ public enum OsType {
private final String name; private final String name;
private final String[] libraryNames; private final String[] libraryNames;
OsType(String name, String... libraryNames) { OSType(String name, String... libraryNames) {
this.name = name; this.name = name;
this.libraryNames = libraryNames; this.libraryNames = libraryNames;
} }
@ -65,23 +65,23 @@ public enum OsType {
public public
boolean is64bit() { boolean is64bit() {
return this == OsType.Linux64 || this == OsType.LinuxArm64 || return this == OSType.Linux64 || this == OSType.LinuxArm64 ||
this == OsType.Windows64 || this == OsType.MacOsX64 || this == OSType.Windows64 || this == OSType.MacOsX64 ||
this == OsType.AndroidArm8 || this == OsType.AndroidX86_64 || this == OsType.AndroidMips64 || this == OSType.AndroidArm8 || this == OSType.AndroidX86_64 || this == OSType.AndroidMips64 ||
this == OsType.Unix64; this == OSType.Unix64;
} }
public public
boolean is32bit() { boolean is32bit() {
return this == OsType.Linux32 || this == OsType.LinuxArm32 || return this == OSType.Linux32 || this == OSType.LinuxArm32 ||
this == OsType.Windows32 || this == OsType.MacOsX32 || this == OSType.Windows32 || this == OSType.MacOsX32 ||
this == OsType.AndroidArm56 || this == OsType.AndroidArm7 || this == OsType.AndroidX86 || this == OsType.AndroidMips || this == OSType.AndroidArm56 || this == OSType.AndroidArm7 || this == OSType.AndroidX86 || this == OSType.AndroidMips ||
this == OsType.UnixArm || this == OsType.Unix32; this == OSType.UnixArm || this == OSType.Unix32;
} }
public public
boolean isMips() { boolean isMips() {
return this == OsType.AndroidMips || this == OsType.AndroidMips64; return this == OSType.AndroidMips || this == OSType.AndroidMips64;
} }
/** /**
@ -89,48 +89,48 @@ public enum OsType {
*/ */
public public
boolean isX86() { boolean isX86() {
return this == OsType.Linux64 || this == OsType.LinuxArm64 || return this == OSType.Linux64 || this == OSType.LinuxArm64 ||
this == OsType.Windows64 || this == OsType.MacOsX64 || this == OSType.Windows64 || this == OSType.MacOsX64 ||
this == OsType.Linux32 || this == OsType.LinuxArm32 || this == OSType.Linux32 || this == OSType.LinuxArm32 ||
this == OsType.Windows32 || this == OsType.MacOsX32 || this == OSType.Windows32 || this == OSType.MacOsX32 ||
this == OsType.Unix32 || this == OsType.Unix64 || this == OSType.Unix32 || this == OSType.Unix64 ||
this == OsType.AndroidX86 || this == OsType.AndroidX86_64; this == OSType.AndroidX86 || this == OSType.AndroidX86_64;
} }
public public
boolean isArm() { boolean isArm() {
return this == OsType.LinuxArm32 || this == OsType.LinuxArm64 || return this == OSType.LinuxArm32 || this == OSType.LinuxArm64 ||
this == OsType.AndroidArm56 || this == OsType.AndroidArm7 || this == OsType.AndroidArm8; this == OSType.AndroidArm56 || this == OSType.AndroidArm7 || this == OSType.AndroidArm8;
} }
public public
boolean isLinux() { boolean isLinux() {
return this == OsType.Linux32 || this == OsType.Linux64 || this == OsType.LinuxArm64 || this == OsType.LinuxArm32; return this == OSType.Linux32 || this == OSType.Linux64 || this == OSType.LinuxArm64 || this == OSType.LinuxArm32;
} }
public public
boolean isUnix() { boolean isUnix() {
return this == OsType.Unix32 || this == OsType.Unix64 || this == OsType.UnixArm; return this == OSType.Unix32 || this == OSType.Unix64 || this == OSType.UnixArm;
} }
public public
boolean isSolaris() { boolean isSolaris() {
return this == OsType.Solaris; return this == OSType.Solaris;
} }
public public
boolean isWindows() { boolean isWindows() {
return this == OsType.Windows64 || this == OsType.Windows32; return this == OSType.Windows64 || this == OSType.Windows32;
} }
public public
boolean isMacOsX() { boolean isMacOsX() {
return this == OsType.MacOsX64 || this == OsType.MacOsX32; return this == OSType.MacOsX64 || this == OSType.MacOsX32;
} }
public public
boolean isAndroid() { boolean isAndroid() {
return this == OsType.AndroidArm56 || this == OsType.AndroidArm7 || this == OsType.AndroidX86 || this == OsType.AndroidMips || return this == OSType.AndroidArm56 || this == OSType.AndroidArm7 || this == OSType.AndroidX86 || this == OSType.AndroidMips ||
this == OsType.AndroidArm8 || this == OsType.AndroidX86_64 || this == OsType.AndroidMips64; this == OSType.AndroidArm8 || this == OSType.AndroidX86_64 || this == OSType.AndroidMips64;
} }
} }