Skip to content

Commit 71d8610

Browse files
committed
os_version: .net too
1 parent d393049 commit 71d8610

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

+stdlib/os_version.m

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,20 @@
77

88
function [os, version] = os_version()
99

10-
os = javaMethod("getProperty", "java.lang.System", "os.name");
11-
version = javaMethod("getProperty", "java.lang.System", "os.version");
10+
if stdlib.has_dotnet()
11+
v = System.Environment.OSVersion.VersionString;
12+
vs = split(string(v), ' ');
13+
version = vs(end);
14+
os = join(vs(1:end-1));
15+
else
16+
os = javaMethod("getProperty", "java.lang.System", "os.name");
17+
version = javaMethod("getProperty", "java.lang.System", "os.version");
18+
try %#ok<*TRYNC>
19+
os = string(os);
20+
version = string(version);
21+
end
22+
end
1223

13-
try %#ok<*TRYNC>
14-
os = string(os);
15-
version = string(version);
1624
end
1725

1826
%!test

0 commit comments

Comments
 (0)