Debian Codegraph @

src/main/java/com/carrotsearch/procfork/LocalEnvironment.java

raw symbols SCIP
1 /*
2 * procfork
3 *
4 * Copyright (C) 2019, Dawid Weiss.
5 * All rights reserved.
6 */
7 package com.carrotsearch.procfork;
8
9 import java.util.Objects;
10
11 final class LocalEnvironment {
12 static final String OS_NAME;
13
14 static final boolean IS_OS_WINDOWS;
15 static final boolean IS_OS_MAC_OSX;
16 static final boolean IS_OS_LINUX;
17
18 static final boolean IS_OS_UNIXISH;
19
20 static final boolean IS_CYGWIN;
21
22 static {
23 OS_NAME = Objects.requireNonNull(System.getProperty("os.name"));
24 IS_OS_WINDOWS = OS_NAME.startsWith("Windows");
25 IS_OS_MAC_OSX = OS_NAME.startsWith("Mac OS X");
26 IS_OS_LINUX = OS_NAME.startsWith("Linux") || OS_NAME.startsWith("LINUX");
27
28 boolean IS_OS_SOLARIS = OS_NAME.startsWith("Solaris");
29 boolean IS_OS_FREE_BSD = OS_NAME.startsWith("FreeBSD");
30 boolean IS_OS_OPEN_BSD = OS_NAME.startsWith("OpenBSD");
31 boolean IS_OS_NET_BSD = OS_NAME.startsWith("NetBSD");
32
33 IS_OS_UNIXISH =
34 IS_OS_LINUX
35 || IS_OS_MAC_OSX
36 || IS_OS_SOLARIS
37 || IS_OS_FREE_BSD
38 || IS_OS_OPEN_BSD
39 || IS_OS_NET_BSD;
40
41 // A crude heuristic but we don't want to run external commands (uname) and still
42 // be able to quickly detect it.
43 IS_CYGWIN =
44 IS_OS_WINDOWS && (System.getenv("SHELL") != null && System.getenv("ORIGINAL_PATH") != null);
45 }
46 }