|
25 | 25 |
|
26 | 26 | package org.opengrok.indexer.web;
|
27 | 27 |
|
| 28 | +import static org.opengrok.indexer.index.Indexer.PATH_SEPARATOR; |
| 29 | + |
28 | 30 | import java.io.BufferedInputStream;
|
29 | 31 | import java.io.File;
|
30 | 32 | import java.io.FileInputStream;
|
|
64 | 66 | import org.opengrok.indexer.history.HistoryGuru;
|
65 | 67 | import org.opengrok.indexer.logger.LoggerFactory;
|
66 | 68 |
|
67 |
| -import static org.opengrok.indexer.index.Indexer.PATH_SEPARATOR; |
68 |
| - |
69 | 69 | /**
|
70 | 70 | * Class for useful functions.
|
71 | 71 | */
|
@@ -848,22 +848,37 @@ public static String fixPathIfWindows(String path) {
|
848 | 848 | return path;
|
849 | 849 | }
|
850 | 850 |
|
| 851 | + /** |
| 852 | + * Determine the operation system name. |
| 853 | + * |
| 854 | + * @return the name in lowercase, {@code null} if unknown |
| 855 | + */ |
851 | 856 | public static String getOsName() {
|
852 | 857 | if (OS == null) {
|
853 |
| - OS = System.getProperty("os.name"); |
| 858 | + OS = System.getProperty("os.name").toLowerCase(Locale.ROOT); |
854 | 859 | }
|
855 | 860 | return OS;
|
856 | 861 | }
|
857 | 862 |
|
| 863 | + /** |
| 864 | + * Determine if the current platform is Windows. |
| 865 | + * |
| 866 | + * @return true if windows, false when not windows or we can not determine |
| 867 | + */ |
858 | 868 | public static boolean isWindows() {
|
859 | 869 | String osname = getOsName();
|
860 |
| - return osname != null ? osname.startsWith("Windows") : false; |
| 870 | + return osname != null ? osname.startsWith("windows") : false; |
861 | 871 | }
|
862 | 872 |
|
| 873 | + /** |
| 874 | + * Determine if the current platform is Unix. |
| 875 | + * |
| 876 | + * @return true if unix, false when not unix or we can not determine |
| 877 | + */ |
863 | 878 | public static boolean isUnix() {
|
864 | 879 | String osname = getOsName();
|
865 |
| - return osname != null ? (osname.startsWith("Linux") || osname.startsWith("Solaris") || |
866 |
| - osname.contains("bsd") || osname.startsWith("mac")): false; |
| 880 | + return osname != null ? (osname.startsWith("linux") || osname.startsWith("solaris") || |
| 881 | + osname.contains("bsd") || osname.startsWith("mac")) : false; |
867 | 882 | }
|
868 | 883 |
|
869 | 884 | /**
|
|
0 commit comments