Skip to content

Commit 17340df

Browse files
committed
optional return backend where used
1 parent e49887d commit 17340df

33 files changed

+209
-70
lines changed

+stdlib/canonical.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
%%% Inputs
1010
% * p: path to make canonical
1111
% * strict: if true, only return canonical path if it exists. If false, return normalized path if path does not exist.
12+
% * backend: backend to use
1213
%%% Outputs
1314
% * c: canonical path, if determined
1415
% * b: backend used

+stdlib/create_symlink.m

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
%% CREATE_SYMLINK create symbolic link
22
%
3-
%%% Inputs
3+
%% Inputs
44
% * target: path to link to
55
% * link: path to create link at
6-
%%% Outputs
6+
%% Outputs
77
% * ok: true if successful
8+
% * b: backend used
89

9-
function ok = create_symlink(target, link, backend)
10+
function [ok, b] = create_symlink(target, link, backend)
1011
arguments
1112
target {mustBeTextScalar}
1213
link {mustBeTextScalar}
1314
backend (1,:) string = ["native", "dotnet", "python", "sys"]
1415
end
1516

16-
fun = hbackend(backend, "create_symlink", 'R2024b');
17+
[fun, b] = hbackend(backend, "create_symlink", 'R2024b');
1718

1819
ok = fun(target, link);
1920

+stdlib/device.m

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
%% DEVICE filesystem device index of path
2+
%
3+
%% Inputs
4+
% * file: path to file
5+
%% Outputs
6+
% * i: device index
7+
% * b: backend used
28

3-
function i = device(file, backend)
9+
function [i, b] = device(file, backend)
410
arguments
511
file {mustBeTextScalar}
612
backend (1,:) string = ["java", "python", "sys"]
713
end
814

9-
fun = hbackend(backend, "device");
15+
[fun, b] = hbackend(backend, "device");
16+
1017
i = fun(file);
1118

1219
end

+stdlib/disk_available.m

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,21 @@
22
%
33
% example: stdlib.disk_available('/')
44
%
5+
%% Inputs
6+
% * filepath: path to check
7+
%% Outputs
8+
% * f: free disk space (bytes)
9+
% * b: backend used
10+
%
511
% Ref: https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/io/File.html#getUsableSpace()
612

7-
function f = disk_available(filepath, backend)
13+
function [f, b] = disk_available(filepath, backend)
814
arguments
915
filepath {mustBeTextScalar}
1016
backend (1,:) string = ["java", "dotnet", "python", "sys"]
1117
end
1218

13-
fun = hbackend(backend, "disk_available");
19+
[fun, b] = hbackend(backend, "disk_available");
1420

1521
f = fun(filepath);
1622

+stdlib/disk_capacity.m

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
%% DISK_CAPACITY disk total capacity (bytes)
22
%
33
% example: stdlib.disk_capacity('/')
4+
%
5+
%% Inputs
6+
% * filepath: path to check
7+
%% Outputs
8+
% * f: total disk capacity (bytes)
9+
% * b: backend used
410

5-
function f = disk_capacity(filepath, backend)
11+
function [f, b] = disk_capacity(filepath, backend)
612
arguments
713
filepath {mustBeTextScalar}
814
backend (1,:) string = ["java", "dotnet", "python", "sys"]
915
end
1016

11-
fun = hbackend(backend, "disk_capacity");
17+
[fun, b] = hbackend(backend, "disk_capacity");
1218

1319
f = fun(filepath);
1420

+stdlib/file_checksum.m

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,18 @@
77
% * method: "MD5", "SHA-1", "SHA-256", etc.
88
%%% Outputs
99
% * hash: string hash
10+
% * b: backend used
1011
%
1112
% Ref: https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/security/MessageDigest.html#getInstance(java.lang.String)
1213

13-
function hash = file_checksum(file, hash_method, backend)
14+
function [hash, b] = file_checksum(file, hash_method, backend)
1415
arguments
1516
file {mustBeTextScalar}
1617
hash_method {mustBeTextScalar}
1718
backend (1,:) string = ["java", "dotnet", "sys"]
1819
end
1920

20-
fun = hbackend(backend, "file_checksum");
21+
[fun, b] = hbackend(backend, "file_checksum");
2122

2223
hash = fun(file, hash_method);
2324

+stdlib/filesystem_type.m

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
%% FILESYSTEM_TYPE tell type of filesystem
22
%
33
% example outputs: NTFS, ext4, apfs, ...
4+
%
5+
%% Inputs
6+
% * file: path to check
7+
%% Outputs
8+
% * t: filesystem type
9+
% * b: backend used
410

5-
function t = filesystem_type(file, backend)
11+
function [t, b] = filesystem_type(file, backend)
612
arguments
713
file {mustBeTextScalar}
814
backend (1,:) string = ["java", "dotnet", "python", "sys"]
915
end
1016

11-
fun = hbackend(backend, "filesystem_type");
17+
[fun, b] = hbackend(backend, "filesystem_type");
1218

1319
t = fun(file);
1420

+stdlib/get_owner.m

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44
% * p: path to examine
55
%%% Outputs
66
% * n: owner, or empty if path does not exist
7+
% * b: backend used
78

8-
function n = get_owner(file, backend)
9+
function [n, b] = get_owner(file, backend)
910
arguments
1011
file {mustBeTextScalar}
1112
backend (1,:) string = ["java", "dotnet", "python", "sys"]
1213
end
1314

14-
fun = hbackend(backend, "get_owner");
15+
[fun, b] = hbackend(backend, "get_owner");
1516

1617
n = fun(file);
1718

+stdlib/get_permissions.m

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
%% GET_PERMISSIONS permissions of file or directory
22
%
33
% output is char like 'rwxrwxr--'
4+
%
5+
%% Inputs
6+
% * file: path to check
7+
%% Outputs
8+
% * p: permissions string
9+
% * b: backend used
410

5-
function p = get_permissions(file, backend)
11+
function [p, b] = get_permissions(file, backend)
612
arguments
713
file {mustBeTextScalar}
814
backend (1,:) string = ["native", "legacy"]
915
end
1016

11-
fun = hbackend(backend, "get_permissions", 'R2025a');
17+
[fun, b] = hbackend(backend, "get_permissions", 'R2025a');
1218

1319
p = fun(file);
1420

+stdlib/get_shell.m

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
%% GET_SHELL full path to currently running shell
2+
%
3+
%% Outputs
4+
% * s: full path to currently running shell
5+
% * b: backend used
26

3-
function s = get_shell()
7+
function [s, b] = get_shell()
48

59
if ispc()
610
% https://stackoverflow.com/a/61469226
@@ -10,6 +14,8 @@
1014
cmd = 'lsof -p "$$" | grep -m 1 txt | xargs -n 1 | tail -n +9';
1115
end
1216

17+
b = "sys";
18+
1319
[r, msg] = system(cmd);
1420

1521
if r == 0

0 commit comments

Comments
 (0)