Changed "getUbuntuVersion" to return the version (major.minor) as an int
array. 0.0 if unknown.
This commit is contained in:
parent
627a99fdc6
commit
ef2f0ad2db
@ -379,27 +379,34 @@ class OSUtil {
|
|||||||
* @return the ubuntu version or "" if not found.
|
* @return the ubuntu version or "" if not found.
|
||||||
*/
|
*/
|
||||||
public static
|
public static
|
||||||
String getUbuntuVersion() {
|
int[] getUbuntuVersion() {
|
||||||
if (!OS.isLinux()) {
|
if (!OS.isLinux()) {
|
||||||
return "";
|
return new int[]{0,0};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isUbuntu()) {
|
if (!isUbuntu()) {
|
||||||
return "";
|
return new int[] {0, 0};
|
||||||
}
|
}
|
||||||
|
|
||||||
String info = getInfo();
|
String info = getInfo();
|
||||||
String releaseString = "DISTRIB_RELEASE=";
|
String releaseString = "DISTRIB_RELEASE=";
|
||||||
int index = info.indexOf(releaseString);
|
int index = info.indexOf(releaseString);
|
||||||
if (index > -1) {
|
try {
|
||||||
index += releaseString.length();
|
if (index > -1) {
|
||||||
int newLine = info.indexOf(OS.LINE_SEPARATOR_UNIX, index);
|
index += releaseString.length();
|
||||||
if (newLine > index) {
|
int newLine = info.indexOf(OS.LINE_SEPARATOR_UNIX, index);
|
||||||
return info.substring(index, newLine);
|
if (newLine > index) {
|
||||||
|
String versionInfo = info.substring(index, newLine);
|
||||||
|
if (versionInfo.indexOf('.') > 0) {
|
||||||
|
String[] split = versionInfo.split("\\.");
|
||||||
|
return new int[] {Integer.parseInt(split[0]), Integer.parseInt(split[1])};
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} catch (Throwable ignored) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return "";
|
return new int[] {0, 0};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user