Skip to content

Commit e49887d

Browse files
committed
optional tell backend
1 parent af53228 commit e49887d

File tree

7 files changed

+40
-17
lines changed

7 files changed

+40
-17
lines changed

+stdlib/canonical.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
% * strict: if true, only return canonical path if it exists. If false, return normalized path if path does not exist.
1212
%%% Outputs
1313
% * c: canonical path, if determined
14+
% * b: backend used
1415

15-
function c = canonical(p, strict, backend)
16+
function [c, b] = canonical(p, strict, backend)
1617
arguments
1718
p string
1819
strict (1,1) logical = false

+stdlib/is_exe.m

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
%% IS_EXE is file executable
2+
% does not check if the file is actually a binary executable
23
%
3-
% false if not a file
4+
%% Inputs
5+
% file: path to check
6+
%% Outputs
7+
% ok: true if path is a file and has executable permissions
8+
% b: backend used
49

5-
function y = is_exe(file, backend)
10+
function [ok, b] = is_exe(file, backend)
611
arguments
712
file string
813
backend (1,:) string = ["java", "python", "native", "legacy"]
@@ -12,9 +17,9 @@
1217
[fun, b] = hbackend(backend, "is_exe", 'R2025a');
1318

1419
if isscalar(file) || b == "native"
15-
y = fun(file);
20+
ok = fun(file);
1621
else
17-
y = arrayfun(fun, file);
22+
ok = arrayfun(fun, file);
1823
end
1924

2025
end

+stdlib/is_readable.m

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
% file: single path string
55
%% Outputs
66
% ok: true if file is readable
7+
% b: backend used
78

8-
function y = is_readable(file, backend)
9+
function [ok, b] = is_readable(file, backend)
910
arguments
1011
file string
1112
backend (1,:) string = ["java", "native", "legacy"]
@@ -14,9 +15,9 @@
1415
[fun, b] = hbackend(backend, "is_readable", 'R2025a');
1516

1617
if isscalar(file) || b == "native"
17-
y = fun(file);
18+
ok = fun(file);
1819
else
19-
y = arrayfun(fun, file);
20+
ok = arrayfun(fun, file);
2021
end
2122

2223
end

+stdlib/is_symlink.m

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
%% IS_SYMLINK is path a symbolic link
2+
%
3+
%% Inputs
4+
% file: path to check
5+
%% Outputs
6+
% ok: true if path is a symbolic link
7+
% b: backend used
28

3-
function ok = is_symlink(file, backend)
9+
function [ok, b] = is_symlink(file, backend)
410
arguments
511
file string
612
backend (1,:) string = ["native", "java", "dotnet", "python", "sys"]

+stdlib/is_writable.m

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
% file: path to file or folder
55
%% Outputs
66
% ok: true if file is writable
7+
% b: backend used
78

8-
function y = is_writable(file, backend)
9+
function [ok, b] = is_writable(file, backend)
910
arguments
1011
file string
1112
backend (1,:) string = ["java", "native", "legacy"]
@@ -14,9 +15,9 @@
1415
[fun, b] = hbackend(backend, "is_writable", 'R2025a');
1516

1617
if isscalar(file) || b == "native"
17-
y = fun(file);
18+
ok = fun(file);
1819
else
19-
y = arrayfun(fun, file);
20+
ok = arrayfun(fun, file);
2021
end
2122

2223
end

+stdlib/read_symlink.m

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,14 @@
22
%
33
% empty string if path is not a symlink
44
% always of string class in Matlab
5+
%
6+
%% Inputs
7+
% file: path to symbolic link
8+
%% Outputs
9+
% r: target of symbolic link
10+
% b: backend used
511

6-
function r = read_symlink(file, backend)
12+
function [r, b] = read_symlink(file, backend)
713
arguments
814
file string
915
backend (1,:) string = ["native", "java", "dotnet", "python", "sys"]

+stdlib/samepath.m

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,13 @@
99
%
1010
% Ref: https://devblogs.microsoft.com/oldnewthing/20220128-00/?p=106201
1111
%
12-
%%% Inputs
12+
%% Inputs
1313
% * path1, path2: paths to compare
14+
%% Outputs
15+
% * ok: true if paths are the same
16+
% * b: backend used
1417

15-
function y = samepath(path1, path2, backend)
18+
function [ok, b] = samepath(path1, path2, backend)
1619
arguments
1720
path1 string
1821
path2 string
@@ -24,9 +27,9 @@
2427
[fun, b] = hbackend(backend, "samepath");
2528

2629
if (isscalar(path1) && isscalar(path2)) || b == "native"
27-
y = fun(path1, path2);
30+
ok = fun(path1, path2);
2831
else
29-
y = arrayfun(fun, path1, path2);
32+
ok = arrayfun(fun, path1, path2);
3033
end
3134

3235
end

0 commit comments

Comments
 (0)