Skip to content

Commit e77cf1e

Browse files
committed
some CI are shaky, use try-catch more efficient
1 parent f7f3d81 commit e77cf1e

File tree

3 files changed

+24
-12
lines changed

3 files changed

+24
-12
lines changed

+stdlib/+java/filesystem_type.m

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
1+
%% JAVA.FILESYSTEM_TYPE
2+
%
3+
% if stdlib.exists() was not adequate here, as on some CI systems, say Windows with Matlab
4+
% R2025a, despite the same setup on a laptop working.
5+
% stdlib.exists() was true, the Java function threw java.nio.file.NoSuchFileException.
6+
%
7+
% this try-catch is faster and more robust
8+
19
function t = filesystem_type(file)
210

3-
if stdlib.exists(file)
11+
try
412
t = char(java.nio.file.Files.getFileStore(javaPathObject(file)).type);
5-
else
13+
catch
614
t = '';
715
end
816

+stdlib/+java/get_owner.m

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
11
%% JAVA.GET_OWNER get owner of file
2+
%
3+
%% JAVA.FILESYSTEM_TYPE
4+
%
5+
% if stdlib.exists() was not adequate here, as on some CI systems, say Windows with Matlab
6+
% R2025a, despite the same setup on a laptop working.
7+
% stdlib.exists() was true, the Java function threw java.nio.file.NoSuchFileException.
8+
%
9+
% this try-catch is faster and more robust
210

311
function n = get_owner(p)
412

513
% 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...)
614
% https://docs.oracle.com/en/java/javase/22/docs/api/java.base/java/nio/file/LinkOption.html
715

8-
if stdlib.exists(p)
16+
try
917
opt = java.nio.file.LinkOption.values();
10-
n = char(java.nio.file.Files.getOwner(javaPathObject(p), opt));
11-
else
12-
n = '';
13-
end
14-
15-
try %#ok<TRYNC>
16-
n = string(n);
18+
n = string(java.nio.file.Files.getOwner(javaPathObject(p), opt));
19+
catch
20+
n = "";
1721
end
1822

1923
end

test/TestDisk.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,14 @@ function test_remove_file(tc)
126126

127127

128128
function test_inode_device(tc, java_python_sys, id_name)
129-
n = "stdlib." + java_python_sys + "." + id_name;
129+
130130
h = str2func("stdlib." + id_name);
131-
tc.assertNotEmpty(which(n))
132131

133132
try
134133
ip = h(pwd(), java_python_sys);
135134
tc.verifyClass(ip, 'uint64')
136135
tc.verifyGreaterThan(ip, 0)
136+
137137
tc.verifyEqual(h(".", java_python_sys), ip)
138138
catch e
139139
tc.verifyEqual(e.identifier, 'stdlib:hbackend:NameError', e.message)

0 commit comments

Comments
 (0)