Skip to content

Commit 0cb38ae

Browse files
committed
fileAttribCompatible: handle string for Matlab < R2018a
1 parent 9a2610d commit 0cb38ae

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

+stdlib/private/fileAttribCompatible.m

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
function [s, r, id] = fileAttribCompatible(file)
44

5+
% need stdlib.strempty for Matlab < R2020b
6+
if stdlib.strempty(file)
7+
r = struct.empty;
8+
s = 0;
9+
id = 'MATLAB:FILEATTRIB:CannotFindFile';
10+
return
11+
end
12+
13+
514
try
615
[s, r, id] = fileattrib(file);
716
catch e

+stdlib/private/file_attributes.m

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,12 @@
11
function a = file_attributes(p)
22

3-
a = struct.empty;
4-
5-
% need stdlib.strempty for Matlab < R2020b
6-
if stdlib.strempty(p)
7-
return
8-
end
9-
10-
[status, s] = fileattrib(p);
3+
[status, a] = fileAttribCompatible(p);
114

125
if status ~= 1
6+
a = struct.empty;
137
return
148
end
159

16-
a = s;
1710
for n = ["GroupRead", "GroupWrite", "GroupExecute", "OtherRead", "OtherWrite", "OtherExecute"]
1811

1912
if ~isfield(a, n) || isnan(a.(n))

0 commit comments

Comments
 (0)