mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-19 14:19:53 +01:00
Merge branch 'backport-os-check-algorithm' into 'master'
Backport OS-check logic from Compose Multiplatform See merge request briar/briar!1785
This commit is contained in:
@@ -4,6 +4,8 @@ import org.briarproject.nullsafety.NotNullByDefault;
|
|||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import static org.briarproject.bramble.util.StringUtils.startsWithIgnoreCase;
|
||||||
|
|
||||||
@NotNullByDefault
|
@NotNullByDefault
|
||||||
public class OsUtils {
|
public class OsUtils {
|
||||||
|
|
||||||
@@ -13,15 +15,15 @@ public class OsUtils {
|
|||||||
private static final String vendor = System.getProperty("java.vendor");
|
private static final String vendor = System.getProperty("java.vendor");
|
||||||
|
|
||||||
public static boolean isWindows() {
|
public static boolean isWindows() {
|
||||||
return os != null && os.contains("Windows");
|
return os != null && startsWithIgnoreCase(os, "Win");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isMac() {
|
public static boolean isMac() {
|
||||||
return os != null && os.contains("Mac OS");
|
return os != null && os.equalsIgnoreCase("Mac OS X");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isLinux() {
|
public static boolean isLinux() {
|
||||||
return os != null && os.contains("Linux") && !isAndroid();
|
return os != null && startsWithIgnoreCase(os, "Linux") && !isAndroid();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isAndroid() {
|
public static boolean isAndroid() {
|
||||||
|
|||||||
@@ -176,4 +176,9 @@ public class StringUtils {
|
|||||||
}
|
}
|
||||||
return new String(c);
|
return new String(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// see https://stackoverflow.com/a/38947571
|
||||||
|
static boolean startsWithIgnoreCase(String s, String prefix) {
|
||||||
|
return s.regionMatches(true, 0, prefix, 0, prefix.length());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user