Skip to content

Commit 72fe9a5

Browse files
committed
more remove of arguments and non-coerce
1 parent febc3e5 commit 72fe9a5

File tree

15 files changed

+26
-52
lines changed

15 files changed

+26
-52
lines changed

+stdlib/+legacy/file_attributes.m

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
function a = file_attributes(p)
2-
arguments
3-
p (1,1) string
4-
end
5-
% need arguments and stdlib.strempty for Matlab < R2020b
62

73
a = struct.empty;
84

5+
% need stdlib.strempty for Matlab < R2020b
96
if stdlib.strempty(p)
107
return
118
end

+stdlib/+native/is_symlink.m

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
function i = is_symlink(file)
22

3-
try
3+
if ~stdlib.matlabOlderThan('R2024b')
44
i = isSymbolicLink(file);
5-
catch e
6-
if e.identifier ~= "MATLAB:UndefinedFunction"
7-
rethrow(e)
8-
end
5+
else
96
i = logical.empty;
107
end
118

+stdlib/+native/read_symlink.m

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
function r = read_symlink(file)
22

3-
try
3+
if ~stdlib.matlabOlderThan('R2024b')
44
[ok, r] = isSymbolicLink(file);
55
if ~ok
66
r = string.empty;
77
end
8-
catch e
9-
if e.identifier ~= "MATLAB:UndefinedFunction"
10-
rethrow(e)
11-
end
8+
else
129
r = string.empty;
1310
end
1411

+stdlib/device.m

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

1010
function [i, b] = device(file, backend)
1111
arguments
12-
file string
12+
file
1313
backend (1,:) string = ["java", "python", "sys"]
1414
end
1515

+stdlib/exists.m

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,12 @@
55
% In C/C++ access() or stat() the same behavior is observed Windows vs Unix.
66
%
77
%%% Inputs
8-
% * p: path to check
8+
% * fpath: path to check
99
%%% Outputs
1010
% * ok: true if exists
1111

12-
function y = exists(p)
13-
arguments
14-
p string
15-
end
12+
function y = exists(fpath)
1613

17-
y = isfile(p) | isfolder(p);
14+
y = isfile(fpath) || isfolder(fpath);
1815

1916
end

+stdlib/expanduser.m

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@
1010
% * e: expanded path
1111

1212
function e = expanduser(file)
13-
arguments
14-
file (1,1) string
15-
end
16-
1713

1814
pat = ['~[/\', filesep, ']+|^~$'];
1915

@@ -25,12 +21,15 @@
2521
return
2622
end
2723

28-
home = string(stdlib.homedir());
24+
home = stdlib.homedir();
2925

3026
if i1 - i0 == 0 || strlength(file) == i1
3127
e = home;
28+
if isstring(file)
29+
e = string(e);
30+
end
3231
else
33-
e = strjoin([home, extractAfter(file, i1)], filesep);
32+
e = append(home, '/', extractAfter(file, i1));
3433
end
3534

3635
end

+stdlib/file_size.m

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
%% FILE_SIZE size in bytes of file
22
%
33
%%% Inputs
4-
% * p: path to file
4+
% * file: path to file
55
%%% Outputs
66
% * s: size in bytes; empty if file does not exist
77

8-
function s = file_size(p)
9-
arguments
10-
p (1,1) string
11-
end
8+
function s = file_size(file)
129

1310
s = [];
1411

15-
d = dir(p);
12+
d = dir(file);
1613

1714
if isscalar(d) && ~d.isdir
1815
s = d.bytes;

+stdlib/get_modtime.m

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
% * t: modification time, or empty if path does not exist
77

88
function t = get_modtime(file)
9-
arguments
10-
file
11-
end
129

1310
t = datetime.empty;
1411

+stdlib/hard_link_count.m

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

1414
function [i, b] = hard_link_count(file, backend)
1515
arguments
16-
file string
16+
file
1717
backend (1,:) string = ["java", "python", "sys"]
1818
end
1919

+stdlib/is_readable.m

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
% this method is like 40x faster than native
99

1010
function y = is_readable(file)
11-
arguments
12-
file (1,1) string
13-
end
1411

1512
a = stdlib.legacy.file_attributes(file);
1613

0 commit comments

Comments
 (0)