This repository has been archived on 2023-11-26. You can view files and clone it, but cannot push or open issues or pull requests.
2020-06-07 21:58:49 +00:00
|
|
|
package com.thebrokenrail.scriptcraft.core.util;
|
2020-04-25 13:33:17 +00:00
|
|
|
|
|
|
|
import java.util.Locale;
|
|
|
|
|
|
|
|
public class OSUtil {
|
|
|
|
private static String getOSName() {
|
|
|
|
String raw = System.getProperty("os.name").toLowerCase(Locale.ROOT);
|
|
|
|
if (raw.contains("mac")) {
|
|
|
|
return "macosx";
|
|
|
|
} else if (raw.contains("linux")) {
|
|
|
|
return "linux";
|
|
|
|
} else if (raw.contains("windows")) {
|
|
|
|
return "windows";
|
|
|
|
} else {
|
|
|
|
return "other";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static String getOS() {
|
|
|
|
String raw = System.getProperty("os.arch");
|
|
|
|
String arch;
|
|
|
|
switch (raw) {
|
|
|
|
case "x86":
|
2020-04-25 17:25:37 +00:00
|
|
|
case "i386":
|
2020-04-25 13:33:17 +00:00
|
|
|
case "i686": {
|
2020-04-25 17:25:37 +00:00
|
|
|
arch = "x86";
|
2020-04-25 13:33:17 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case "amd64": {
|
|
|
|
arch = "x86_64";
|
|
|
|
break;
|
|
|
|
}
|
2020-04-25 17:25:37 +00:00
|
|
|
case "arm": {
|
|
|
|
arch = "armhf";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case "aarch64_be":
|
|
|
|
case "armv8b":
|
|
|
|
case "armv8l":
|
|
|
|
case "aarch64": {
|
|
|
|
arch = "arm64";
|
|
|
|
break;
|
|
|
|
}
|
2020-04-25 13:33:17 +00:00
|
|
|
default: {
|
|
|
|
arch = "other";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return getOSName() + '-' + arch;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static String getLibExtension() {
|
|
|
|
switch (getOSName()) {
|
|
|
|
case "macos": {
|
|
|
|
return ".dylib";
|
|
|
|
}
|
|
|
|
case "linux": {
|
|
|
|
return ".so";
|
|
|
|
}
|
|
|
|
case "windows": {
|
|
|
|
return ".dll";
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|