Skip to content

Commit 6178075

Browse files
committed
get_permissions: just file mode, add exe test
1 parent 8ca2870 commit 6178075

File tree

4 files changed

+18
-5
lines changed

4 files changed

+18
-5
lines changed

+stdlib/+legacy/get_permissions.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
p = '';
44

55
if stdlib.exists(file)
6-
p = stdlib.native.perm2char(file_attributes(file), file);
6+
p = stdlib.native.perm2char(file_attributes(file));
77
end
88

99
end

+stdlib/+native/get_permissions.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
p = '';
44

55
if stdlib.exists(file)
6-
p = stdlib.native.perm2char(filePermissions(file), file);
6+
p = stdlib.native.perm2char(filePermissions(file));
77
end
88

99
end

+stdlib/+native/perm2char.m

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
%% NATIVE.PERM2CHAR convert file permissions to permission string
22

3-
function p = perm2char(v, file)
3+
function p = perm2char(v)
44
arguments
55
v (1,1)
6-
file {mustBeTextScalar}
76
end
87

98

@@ -23,7 +22,7 @@
2322

2423
if isa(v, "matlab.io.WindowsPermissions") || ispc()
2524

26-
if p(1) == 'r' && stdlib.native.has_windows_executable_suffix(file)
25+
if p(1) == 'r'
2726
p(3) = 'x';
2827
end
2928

test/TestPermissions.m

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,20 @@ function test_get_permissions(tc, Ps, fname)
3737
end
3838

3939

40+
function test_get_permissions_exe(tc)
41+
matlab_exe = fullfile(matlabroot, "bin/matlab");
42+
if ispc()
43+
matlab_exe = matlab_exe + ".exe";
44+
end
45+
46+
tc.assertThat(matlab_exe, matlab.unittest.constraints.IsFile)
47+
p = stdlib.get_permissions(matlab_exe);
48+
tc.assertNotEmpty(p)
49+
tc.verifyEqual(p(3), 'x')
50+
51+
end
52+
53+
4054
function test_set_permissions_noread(tc)
4155
import matlab.unittest.constraints.StartsWithSubstring
4256

0 commit comments

Comments
 (0)