mirror of
https://github.com/SlimeVR/SlimeVR-Server.git
synced 2026-11-20 00:51:20 -08:00
Merge remote-tracking branch 'gui/main' into merge-gui-and-server
This commit is contained in:
commit
ae94de39b1
430 files changed
+44297
-50
No files matched your search
@@ -0,0 +1,47 @@
|
||||
package io.eiren.util;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
|
||||
public enum OperatingSystem {
|
||||
|
||||
//@formatter:off
|
||||
LINUX("linux", new String[]{"linux", "unix"}),
|
||||
WINDOWS("windows", new String[]{"win"}),
|
||||
OSX("osx", new String[]{"mac"}),
|
||||
UNKNOWN("unknown", new String[0]);
|
||||
//@fomatter: on
|
||||
|
||||
private final String[] aliases;
|
||||
public final String name;
|
||||
private static OperatingSystem currentPlatform;
|
||||
|
||||
private OperatingSystem(String name, String[] aliases) {
|
||||
this.aliases = aliases;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public static String getJavaExecutable(boolean forceConsole) {
|
||||
String separator = System.getProperty("file.separator");
|
||||
String path = System.getProperty("java.home") + separator + "bin" + separator;
|
||||
if(getCurrentPlatform() == WINDOWS) {
|
||||
if(!forceConsole && new File(path + "javaw.exe").isFile())
|
||||
return path + "javaw.exe";
|
||||
return path + "java.exe";
|
||||
}
|
||||
return path + "java";
|
||||
}
|
||||
|
||||
public static OperatingSystem getCurrentPlatform() {
|
||||
if(currentPlatform != null)
|
||||
return currentPlatform;
|
||||
String osName = System.getProperty("os.name").toLowerCase();
|
||||
for(OperatingSystem os : values()) {
|
||||
for(String alias : os.aliases) {
|
||||
if(osName.contains(alias))
|
||||
return currentPlatform = os;
|
||||
}
|
||||
}
|
||||
return UNKNOWN;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user