File tree Expand file tree Collapse file tree 9 files changed +34
-23
lines changed Expand file tree Collapse file tree 9 files changed +34
-23
lines changed Original file line number Diff line number Diff line change 33
44function a = cpu_arch()
55
6- if NET . isNETSupported
6+ if stdlib .has_dotnet()
77 a = System .Runtime .InteropServices .RuntimeInformation .OSArchitecture ;
88else
99 a = javaMethod(" getProperty" , " java.lang.System" , " os.arch" );
Original file line number Diff line number Diff line change 88
99i = [];
1010
11- if ispc()
11+ if ispc() && stdlib .has_dotnet()
1212 h = NET .addAssembly(' System.Management' );
1313
1414 r = stdlib .root_name(path );
Original file line number Diff line number Diff line change 1313f = uint64(0 );
1414if ~stdlib .exists(d ), return , end
1515
16- if NET . isNETSupported
16+ if stdlib .has_dotnet()
1717 f = System .IO .DriveInfo(stdlib .absolute(d )).AvailableFreeSpace();
18- else
18+ elseif stdlib .has_java()
1919 f = javaMethod(" getUsableSpace" , " java.io.File" , d );
2020 f = uint64(f );
2121end
Original file line number Diff line number Diff line change 1111f = uint64(0 );
1212if ~stdlib .exists(d ), return , end
1313
14- if NET . isNETSupported
14+ if stdlib .has_dotnet()
1515 f = System .IO .DriveInfo(stdlib .absolute(d )).TotalSize();
16- else
16+ elseif stdlib .has_java()
1717 f = javaMethod(" getTotalSpace" , " java.io.File" , d );
1818 f = uint64(f );
1919end
Original file line number Diff line number Diff line change 1111t = " " ;
1212if ~stdlib .exists(p ), return , end
1313
14- if NET . isNETSupported
15- t = string( System .IO .DriveInfo(stdlib .absolute(p )).DriveFormat) ;
16- else
14+ if stdlib .has_dotnet()
15+ t = System .IO .DriveInfo(stdlib .absolute(p )).DriveFormat;
16+ elseif stdlib .has_java()
1717 op = javaPathObject(p );
1818
19- if stdlib .isoctave()
20- t = javaMethod(" getFileStore" , " java.nio.file.Files" , op ).type;
21- else
22- t = java .nio .file .Files .getFileStore(op ).type.string;
23- end
19+ t = javaMethod(" getFileStore" , " java.nio.file.Files" , op ).type;
20+ end
21+
22+ try % #ok<*TRYNC>
23+ t = string(t );
24+ end
25+
2426end
2527
2628% !assert(!isempty(filesystem_type(pwd)))
Original file line number Diff line number Diff line change 33%
44function n = get_username()
55
6- if NET .isNETSupported
6+ n = ' ' ;
7+
8+ if stdlib .has_dotnet()
79 n = System .Environment .UserName ;
8- else
10+ elseif stdlib .has_java()
911 n = javaMethod(" getProperty" , " java.lang.System" , " user.name" );
1012end
1113
Original file line number Diff line number Diff line change 11%% HAS_JAVA detect if JVM is available
2- % requires: java
32
43function y = has_java()
54
Original file line number Diff line number Diff line change 66
77function n = hostname()
88
9- if NET .isNETSupported
10- n = string(System .Environment .MachineName );
9+ n = ' ' ;
10+
11+ if stdlib .has_dotnet()
12+ n = System .Environment .MachineName ;
1113elseif stdlib .isoctave()
1214 n = gethostname();
13- else
14- n = string(java .net .InetAddress .getLocalHost().getHostName());
15+ elseif stdlib .has_java()
16+ n = java .net .InetAddress .getLocalHost().getHostName();
17+ end
18+
19+ try % #ok<*TRYNC>
20+ n = string(n );
1521end
1622
1723end
Original file line number Diff line number Diff line change 99
1010function bytes = ram_total()
1111
12+ bytes = uint64(0 );
13+
1214% .NET is about 10 times SLOWER than Java
13- if ispc() && ~stdlib .has_java()
15+ if ispc() && ~stdlib .has_java() && stdlib .has_dotnet()
1416 h = NET .addAssembly(' Microsoft.VisualBasic' );
1517 ci = Microsoft .VisualBasic .Devices .ComputerInfo();
1618 bytes = ci .TotalPhysicalMemory ;
1719 delete(h );
18- else
20+ elseif stdlib .has_java()
1921 b = javaOSBean();
2022
2123 if stdlib .java_api() < 14
You can’t perform that action at this time.
0 commit comments