Skip to content

Commit 9a2610d

Browse files
committed
more robustness across matlab versions
1 parent 7f704fa commit 9a2610d

File tree

8 files changed

+30
-8
lines changed

8 files changed

+30
-8
lines changed

+stdlib/canonical.m

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

25-
[s, r] = fileattrib(file);
25+
[s, r] = fileAttribCompatible(file);
2626

2727
if s == 1
2828
c = r.Name;

+stdlib/get_permissions.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
catch e
1717
switch e.identifier
1818
case 'MATLAB:UndefinedFunction'
19-
perm = perm2char(stdlib.legacy.file_attributes(file));
19+
perm = perm2char(file_attributes(file));
2020
b = 'legacy';
2121
case 'MATLAB:io:filesystem:filePermissions:CannotFindLocation'
2222
perm = '';

+stdlib/is_exe.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
return
1717
end
1818

19-
a = stdlib.legacy.file_attributes(file);
19+
a = file_attributes(file);
2020

2121
if ~isempty(a)
2222
y = ~a.directory && (a.UserExecute || a.GroupExecute || a.OtherExecute);

+stdlib/is_readable.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
function y = is_readable(file)
1111

12-
a = stdlib.legacy.file_attributes(file);
12+
a = file_attributes(file);
1313

1414
if isempty(a)
1515
y = false;

+stdlib/is_writable.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
function y = is_writable(file)
1111

12-
a = stdlib.legacy.file_attributes(file);
12+
a = file_attributes(file);
1313

1414
if isempty(a)
1515
y = false;

+stdlib/perl_exe.m

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,20 @@
1212

1313
ps = [fileparts(mfilename("fullpath")), '/private/executable.pl'];
1414

15-
[r, s] = perl(ps);
15+
exe = string.empty;
16+
17+
try
18+
[r, s] = perl(ps);
19+
catch e
20+
if strcmp(e.identifier, 'MATLAB:perl:FileNotFound')
21+
return
22+
end
23+
rethrow(e)
24+
end
1625

1726
if s == 0 && isfile(r)
1827
exe = r;
1928
perle = r;
20-
else
21-
exe = string.empty;
2229
end
2330

2431
end
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
%% FILEATTRIBCOMPATIBLE fileattrib required char until R2018a; this provides a seamless fallback
2+
3+
function [s, r, id] = fileAttribCompatible(file)
4+
5+
try
6+
[s, r, id] = fileattrib(file);
7+
catch e
8+
if strcmp(e.identifier, 'MATLAB:string')
9+
[s, r, id] = fileattrib(char(file));
10+
else
11+
rethrow(e)
12+
end
13+
end
14+
15+
end
File renamed without changes.

0 commit comments

Comments
 (0)