Skip to content

Commit cf51835

Browse files
tulinkryVladimir Kotal
authored andcommitted
fixing behavior of isUnix for macosx
1 parent dcdc6c0 commit cf51835

File tree

1 file changed

+21
-6
lines changed
  • opengrok-indexer/src/main/java/org/opengrok/indexer/web

1 file changed

+21
-6
lines changed

opengrok-indexer/src/main/java/org/opengrok/indexer/web/Util.java

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525

2626
package org.opengrok.indexer.web;
2727

28+
import static org.opengrok.indexer.index.Indexer.PATH_SEPARATOR;
29+
2830
import java.io.BufferedInputStream;
2931
import java.io.File;
3032
import java.io.FileInputStream;
@@ -64,8 +66,6 @@
6466
import org.opengrok.indexer.history.HistoryGuru;
6567
import org.opengrok.indexer.logger.LoggerFactory;
6668

67-
import static org.opengrok.indexer.index.Indexer.PATH_SEPARATOR;
68-
6969
/**
7070
* Class for useful functions.
7171
*/
@@ -848,22 +848,37 @@ public static String fixPathIfWindows(String path) {
848848
return path;
849849
}
850850

851+
/**
852+
* Determine the operation system name.
853+
*
854+
* @return the name in lowercase, {@code null} if unknown
855+
*/
851856
public static String getOsName() {
852857
if (OS == null) {
853-
OS = System.getProperty("os.name");
858+
OS = System.getProperty("os.name").toLowerCase(Locale.ROOT);
854859
}
855860
return OS;
856861
}
857862

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+
*/
858868
public static boolean isWindows() {
859869
String osname = getOsName();
860-
return osname != null ? osname.startsWith("Windows") : false;
870+
return osname != null ? osname.startsWith("windows") : false;
861871
}
862872

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+
*/
863878
public static boolean isUnix() {
864879
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;
867882
}
868883

869884
/**

0 commit comments

Comments
 (0)