Skip to content

Commit fce36d2

Browse files
committed
permissions broad compatibility
1 parent 0c690bf commit fce36d2

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

+stdlib/private/perm2char.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
return
2424
end
2525

26-
if isa(v, "matlab.io.WindowsPermissions") || ispc()
26+
if isa(v, 'matlab.io.WindowsPermissions') || ispc()
2727

2828
if p(1) == 'r'
2929
p(3) = 'x';

example/+javafun/jPosix.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
if isempty(o)
66
s = "";
7-
elseif isa(o, "java.io.File") || isa(o, "java.nio.file.Path") || ...
8-
isa(o, "sun.nio.fs.UnixPath") || isa(o, "sun.nio.fs.WindowsPath")
7+
elseif isa(o, 'java.io.File') || isa(o, 'java.nio.file.Path') || ...
8+
isa(o, 'sun.nio.fs.UnixPath') || isa(o, 'sun.nio.fs.WindowsPath')
99
s = o.toString();
1010
end
1111

test/TestPermissions.m

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
classdef (SharedTestFixtures={ matlab.unittest.fixtures.PathFixture(fileparts(fileparts(mfilename('fullpath'))))}, ...
2-
TestTags = {'impure'}) ...
1+
classdef (SharedTestFixtures={ matlab.unittest.fixtures.PathFixture(fileparts(fileparts(mfilename('fullpath'))))}) ...
32
TestPermissions < matlab.unittest.TestCase
43

54
properties (TestParameter)
@@ -9,12 +8,12 @@
98

109
methods(TestMethodSetup)
1110
function w_dirs(tc)
12-
tc.applyFixture(matlab.unittest.fixtures.WorkingFolderFixture())
11+
tc.applyFixture(matlab.unittest.fixtures.WorkingFolderFixture());
1312
end
1413
end
1514

1615

17-
methods (Test, TestTags={'R2019b'})
16+
methods (Test, TestTags={'R2017b'})
1817

1918
function test_get_permissions(tc, Ps)
2019
import matlab.unittest.constraints.StartsWithSubstring
@@ -32,17 +31,17 @@ function test_get_permissions(tc, Ps)
3231
end
3332

3433
tc.verifyThat(p, StartsWithSubstring("r"))
35-
if isfile(p) && stdlib.suffix(p) == ".m"
34+
if isfile(p) && strcmp(stdlib.suffix(p), '.m')
3635
tc.verifyEqual(p(3), '-')
3736
end
3837
end
3938
end
4039

4140

4241
function test_get_permissions_exe(tc)
43-
matlab_exe = fullfile(matlabroot, "bin/matlab");
42+
matlab_exe = [matlabroot, '/bin/matlab'];
4443
if ispc()
45-
matlab_exe = matlab_exe + ".exe";
44+
matlab_exe = [matlab_exe, '.exe'];
4645
end
4746

4847
tc.assertThat(matlab_exe, matlab.unittest.constraints.IsFile)
@@ -57,7 +56,7 @@ function test_get_permissions_exe(tc)
5756
function test_set_permissions_nowrite(tc)
5857
import matlab.unittest.constraints.StartsWithSubstring
5958

60-
nw = fullfile(pwd(), "no-write");
59+
nw = [pwd(), '/no-write'];
6160

6261
tc.assertTrue(stdlib.touch(nw))
6362
r = stdlib.set_permissions(nw, 0, -1, 0);
@@ -72,7 +71,7 @@ function test_set_permissions_nowrite(tc)
7271
tc.assertEqual(b, 'native')
7372
end
7473

75-
if ~ispc() || b ~= "legacy"
74+
if ~ispc() || ~strcmp(b, 'legacy')
7675
tc.verifyThat(p, StartsWithSubstring("r-"), "no-write permission failed to set")
7776
end
7877

@@ -90,7 +89,7 @@ function test_set_permissions_noread(tc)
9089
% fileattrib can not even set the permissions on Linux.
9190
tc.assumeFalse(stdlib.matlabOlderThan('R2025a'))
9291

93-
nr = fullfile(pwd(), "no-read");
92+
nr = [pwd(), '/no-read'];
9493

9594
tc.assertTrue(stdlib.touch(nr))
9695
tc.assertTrue(stdlib.set_permissions(nr, -1, 0, 0))

0 commit comments

Comments
 (0)