forked from runtimeverification/k
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathOS.java
More file actions
38 lines (32 loc) · 1.14 KB
/
OS.java
File metadata and controls
38 lines (32 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Copyright (c) 2014-2018 K Team. All Rights Reserved.
package org.kframework.utils;
import org.kframework.utils.errorsystem.KEMException;
public enum OS {
OSX(true), LINUX(true), UNKNOWN(false), WINDOWS(false);
private OS(boolean isPosix) {
this.isPosix = isPosix;
}
public final boolean isPosix;
public static OS current() {
String osString = System.getProperty("os.name").toLowerCase();
if (osString.contains("nix") || osString.contains("nux"))
return OS.LINUX;
else if (osString.contains("win"))
return OS.WINDOWS;
else if (osString.contains("mac"))
return OS.OSX;
else
return OS.UNKNOWN;
}
public String getNativeExecutable(String executable) {
if (this == UNKNOWN) {
throw KEMException.internalError(
"Unknown OS type. " + System.getProperty("os.name") + " not recognized. " +
"Please contact K developers with details of your OS.");
}
if (this == WINDOWS) {
executable = executable + ".exe";
}
return executable;
}
}