Skip to content

Commit a5f0308

Browse files
committed
consolidate
1 parent 58278bc commit a5f0308

File tree

5 files changed

+16
-14
lines changed

5 files changed

+16
-14
lines changed

+stdlib/filesystem_type.m

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@
1414
if stdlib.has_dotnet()
1515
t = System.IO.DriveInfo(stdlib.absolute(p)).DriveFormat;
1616
elseif stdlib.has_java()
17-
op = javaPathObject(p);
18-
19-
t = javaMethod("getFileStore", "java.nio.file.Files", op).type;
17+
t = javaMethod("getFileStore", "java.nio.file.Files", javaPathObject(p)).type;
2018
end
2119

2220
try %#ok<*TRYNC>

+stdlib/get_owner.m

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,14 @@
1313
% https://docs.oracle.com/en/java/javase/22/docs/api/java.base/java/nio/file/Files.html#getOwner(java.nio.file.Path,java.nio.file.LinkOption...)
1414
% https://docs.oracle.com/en/java/javase/22/docs/api/java.base/java/nio/file/LinkOption.html
1515

16-
op = javaPathObject(p);
1716
opt = javaMethod("values", "java.nio.file.LinkOption");
1817

19-
n = javaMethod("getOwner", "java.nio.file.Files", op, opt).toString();
18+
n = javaMethod("getOwner", "java.nio.file.Files", javaPathObject(p), opt).toString();
19+
% .toString() needed for Octave
20+
21+
try %#ok<*TRYNC>
22+
n = string(n);
23+
end
2024

2125
end
2226

+stdlib/get_pid.m

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66
pid = matlabProcessID;
77
catch e
88
switch e.identifier
9-
case "MATLAB:UndefinedFunction", pid = uint64(feature("getpid"));
10-
case "Octave:undefined-function", pid = uint64(getpid());
9+
case "MATLAB:UndefinedFunction", pid = feature("getpid");
10+
case "Octave:undefined-function", pid = getpid();
1111
otherwise, rethrow(e)
1212
end
13+
14+
pid = uint64(pid);
1315
end
1416

1517
end

+stdlib/has_dotnet.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
%% HAS_DOTNET check if .NET is available
22
function tf = has_dotnet()
33

4-
tf = ~isMATLABReleaseOlderThan('R2023a') && NET.isNETSupported;
4+
tf = ~stdlib.isoctave() && ~isMATLABReleaseOlderThan('R2023a') && NET.isNETSupported;
55

66
end

+stdlib/private/javaPathObject.m

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
%% JAVAPATHOBJECT Return a Java nio.file.Path object for a given file path.
22
function o = javaPathObject(p)
33

4-
if stdlib.isoctave()
5-
o = javaObject("java.io.File", p).toPath();
6-
else
7-
o = java.nio.file.Paths.get(p, javaArray('java.lang.String', 0));
8-
% o = javaObject("java.io.File", p).toPath(); % above way about 20% faster
9-
end
4+
o = javaMethod("get", "java.nio.file.Paths", p, javaArray('java.lang.String', 0));
5+
6+
% o = javaObject("java.io.File", p).toPath();
7+
% javaArray way about 20% faster
108

119
end

0 commit comments

Comments
 (0)