Skip to content

Commit 8134219

Browse files
committed
getpid: broader compatibility
1 parent ccf0083 commit 8134219

File tree

5 files changed

+15
-14
lines changed

5 files changed

+15
-14
lines changed

+stdlib/get_pid.m

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,17 @@
22

33
function pid = get_pid()
44

5-
if stdlib.matlabOlderThan('R2025a')
6-
pid = feature('getpid'); %#ok<FEATGPID>
7-
else
5+
try
86
pid = matlabProcessID;
7+
catch e
8+
switch e.identifier
9+
case 'MATLAB:UndefinedFunction'
10+
pid = feature('getpid');
11+
case 'Octave:undefined-function'
12+
pid = getpid();
13+
otherwise
14+
rethrow(e)
15+
end
916
end
1017

1118
pid = uint64(pid);

+stdlib/is_exe.m

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22
% does not check if the file is actually a binary executable
33
%
44
%%% inputs
5-
% file: path to check
5+
% * file: path to check
66
%%% Outputs
7-
% ok: true if path is a file and has executable permissions
8-
%
9-
% this method is like 40x faster than native.
7+
% * y: true if path is a file and has executable permissions
108

119
function y = is_exe(file)
1210

+stdlib/is_readable.m

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
%% IS_READABLE is file readable
22
%
33
%%% Inputs
4-
% file: single path string
4+
% * file: single path string
55
%%% Outputs
6-
% y: true if file is readable
7-
%
8-
% this method is like 40x faster than native
6+
% * y: true if file is readable
97

108
function y = is_readable(file)
119

+stdlib/is_writable.m

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
% * file: path to file or folder
55
%%% Outputs
66
% * y: true if file is writable
7-
%
8-
% this method is like 40x faster than native
97

108
function y = is_writable(file)
119

Readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Matlab R2017a and newer:
2323
test_main
2424
```
2525

26-
For the functions compatible with GNU Octave:
26+
For the functions compatible with GNU Octave, from the matlab-stdlib/ directory:
2727

2828
```octave
2929
addpath(pwd)

0 commit comments

Comments
 (0)