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.
FreshCoffee/src/main/java/com/thebrokenrail/freshcoffee/util/PlatformUtil.java

57 lines
1.4 KiB
Java

package com.thebrokenrail.freshcoffee.util;
import java.util.Locale;
public final class PlatformUtil {
private static String getPlatformType() {
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 "win";
} else {
return "other";
}
}
private static String getArchitectureType() {
String raw = System.getProperty("os.arch");
switch (raw) {
case "x86":
case "i386":
case "i686": {
return "i686";
}
case "amd64": {
return "x64";
}
case "arm": {
return "arm32";
}
case "aarch64_be":
case "armv8b":
case "armv8l":
case "aarch64": {
return "aarch64";
}
default: {
return "other";
}
}
}
public static String getPlatform() {
return getPlatformType() + '-' + getArchitectureType();
}
static String getExecutableExtension() {
if ("win".equals(getPlatformType())) {
return ".exe";
} else {
return "";
}
}
}