Skip to content

Commit c5b2b22

Browse files
committed
get_permissions: handle non-exist path
1 parent 24dc8f5 commit c5b2b22

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

+stdlib/get_permissions.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
try
1313
v = filePermissions(f);
1414
catch e
15-
if ~strcmp(e.identifier, "MATLAB:UndefinedFunction") && ...
15+
if strcmp(e.identifier, "MATLAB:io:filesystem:filePermissions:CannotFindLocation")
16+
return
17+
elseif ~strcmp(e.identifier, "MATLAB:UndefinedFunction") && ...
1618
~strcmp(e.identifier, "Octave:undefined-function")
1719
rethrow(e)
1820
end

test/TestFileImpure.m

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ function test_makedir(tc)
6464

6565
%%
6666
function test_samepath(tc, p_same)
67-
tc.verifyEqual(stdlib.samepath(p_same{1}, p_same{2}), p_same{3})
67+
tc.verifyEqual(stdlib.samepath(p_same{1}, p_same{2}), p_same{3}, "samepath(" + p_same{1} + "," + p_same{2} + ")")
6868
end
6969

7070

@@ -80,6 +80,9 @@ function test_get_permissions(tc)
8080
p = stdlib.get_permissions(".");
8181
tc.verifyThat(p, StartsWithSubstring("r"))
8282
tc.verifyThat(p, IsOfClass("char"))
83+
84+
p = stdlib.get_permissions(tempname);
85+
tc.verifyEmpty(p)
8386
end
8487

8588
function test_handle2filename(tc, ph)

0 commit comments

Comments
 (0)