Skip to content

Commit 63db420

Browse files
committed
efficiency, doc
1 parent 9864bd5 commit 63db420

File tree

8 files changed

+16
-13
lines changed

8 files changed

+16
-13
lines changed

+stdlib/+legacy/is_exe.m

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
function y = is_exe(file)
2-
arguments
3-
file (1,1) string
4-
end
52

63
y = false;
74

85
if ispc() && ~stdlib.native.has_windows_executable_suffix(file)
96
return
107
end
118

12-
if ~isfile(file), return, end
9+
if ~isfile(file)
10+
return
11+
end
1312

1413
a = stdlib.legacy.file_attributes(file);
1514
y = a.UserExecute || a.GroupExecute || a.OtherExecute;

+stdlib/+native/has_windows_executable_suffix.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
end
1010
pe = split(string(pec), pathsep);
1111

12-
i = endsWith(stdlib.suffix(p), pe, 'IgnoreCase', true);
12+
i = endsWith(stdlib.suffix(p), pe, IgnoreCase=true);
1313

1414
end

+stdlib/get_shell.m

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,16 @@
44
% * s: full path to currently running shell
55
% * b: backend used
66

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

99
if ispc()
1010
% https://stackoverflow.com/a/61469226
11-
cmd = "(dir 2>&1 *`|echo CMD);&<# rem #>echo ($PSVersionTable).PSEdition";
11+
cmd = '(dir 2>&1 *`|echo CMD);&<# rem #>echo ($PSVersionTable).PSEdition';
1212
else
1313
% https://askubuntu.com/a/1349538
1414
cmd = 'lsof -p "$$" | grep -m 1 txt | xargs -n 1 | tail -n +9';
1515
end
1616

17-
b = "sys";
18-
1917
[r, msg] = system(cmd);
2018

2119
if r == 0

+stdlib/is_exe.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
% file: path to check
66
%%% Outputs
77
% ok: true if path is a file and has executable permissions
8+
%
9+
% the legacy backend is actually significantly faster for single files
810

911
function [ok, b] = is_exe(file)
1012
arguments

+stdlib/is_readable.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
% file: single path string
55
%%% Outputs
66
% ok: true if file is readable
7+
%
8+
% the legacy backend is actually significantly faster for single files
79

810
function [ok, b] = is_readable(file)
911
arguments

+stdlib/is_rosetta.m

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,10 @@
77
%
88
% "uname -m" reports "x86_64" from within Matlab on Apple Silicon if using Rosetta
99

10-
function [r, b] = is_rosetta()
11-
12-
b = "sys";
10+
function r = is_rosetta()
1311

1412
if ismac()
15-
[s, raw] = system("sysctl -n sysctl.proc_translated");
13+
[s, raw] = system('sysctl -n sysctl.proc_translated');
1614
r = s == 0 && startsWith(raw, '1');
1715
else
1816
r = false;

+stdlib/is_writable.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
% * file: path to file or folder
55
%%% Outputs
66
% * ok: true if file is writable
7+
%
8+
% the legacy backend is actually significantly faster for single files
79

810
function [ok, b] = is_writable(file)
911
arguments

+stdlib/set_permissions.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
%%% Outputs
99
% * ok (1,1) logical
1010
% * b: backend used
11+
%
12+
% native backend is much more robust, if available
1113

1214
function [ok, b] = set_permissions(file, readable, writable, executable)
1315
arguments

0 commit comments

Comments
 (0)