File tree Expand file tree Collapse file tree 5 files changed +34
-56
lines changed Expand file tree Collapse file tree 5 files changed +34
-56
lines changed Original file line number Diff line number Diff line change 4
4
5
5
function ok = is_exe(p )
6
6
arguments
7
- p { mustBeTextScalar }
7
+ p string
8
8
end
9
+ % need to have string array type for p(:)
9
10
10
- if ~isfile(p )
11
- ok = false ;
12
- return
11
+ if ~stdlib .isoctave() && ~isMATLABReleaseOlderThan(' R2025a' )
12
+ if isunix
13
+ props = [" UserExecute" , " GroupExecute" , " OtherExecute" ];
14
+ else
15
+ props = " Readable" ;
16
+ end
17
+ t = getPermissions(filePermissions(p ), props );
18
+ ok = isfile(p(: )) & any(t{: ,: }, 2 );
19
+ else
20
+ a = file_attributes_legacy(p );
21
+ ok = isfile(p ) && (a .UserExecute || a .GroupExecute || a .OtherExecute );
13
22
end
14
23
15
- try
16
- a = filePermissions(p );
17
- ok = a .UserExecute || (isa(a , " matlab.io.UnixPermissions" ) && (a .GroupExecute || a .OtherExecute ));
18
- catch e
19
- switch e .identifier
20
- case {' Octave:undefined-function' , ' MATLAB:UndefinedFunction' }
21
- a = file_attributes_legacy(p );
22
- ok = ~isempty(a ) && (a .UserExecute || a .GroupExecute || a .OtherExecute );
23
- otherwise , rethrow(e )
24
- end
25
24
end
26
25
27
26
% !assert (!is_exe("."))
Original file line number Diff line number Diff line change 1
1
%% IS_READABLE is file readable
2
2
3
3
function ok = is_readable(p )
4
- arguments
5
- p {mustBeTextScalar }
6
- end
7
4
8
- try
9
- a = filePermissions(p );
10
- ok = a .Readable || (isa(a , " matlab.io.UnixPermissions" ) && (a .GroupRead || a .OtherRead ));
11
- catch e
12
- switch e .identifier
13
- case {' Octave:undefined-function' , ' MATLAB:UndefinedFunction' }
14
- a = file_attributes_legacy(p );
15
- ok = ~isempty(a ) && (a .UserRead || a .GroupRead || a .OtherRead );
16
- otherwise , rethrow(e )
5
+ if ~stdlib .isoctave() && ~isMATLABReleaseOlderThan(' R2025a' )
6
+ props = " Readable" ;
7
+ if isunix
8
+ props = [props , " GroupRead" , " OtherRead" ];
17
9
end
10
+ t = getPermissions(filePermissions(p ), props );
11
+ ok = any(t{: ,: }, 2 );
12
+ else
13
+ a = file_attributes_legacy(p );
14
+ ok = a .UserRead || a .GroupRead || a .OtherRead ;
18
15
end
19
16
20
17
% !assert (is_readable('is_readable.m'))
Original file line number Diff line number Diff line change 1
1
%% IS_WRITABLE is path writable
2
2
3
3
function ok = is_writable(p )
4
- arguments
5
- p {mustBeTextScalar }
6
- end
7
4
8
- try
9
- a = filePermissions(p );
10
- ok = a .Writable || (isa(a , " matlab.io.UnixPermissions" ) && (a .GroupWrite || a .OtherWrite ));
11
- catch e
12
- switch e .identifier
13
- case {' Octave:undefined-function' , ' MATLAB:UndefinedFunction' }
14
- a = file_attributes_legacy(p );
15
- ok = ~isempty(a ) && (a .UserWrite || a .GroupWrite || a .OtherWrite );
16
- otherwise , rethrow(e )
5
+ if ~stdlib .isoctave() && ~isMATLABReleaseOlderThan(' R2025a' )
6
+ props = " Writable" ;
7
+ if isunix
8
+ props = [props , " GroupWrite" , " OtherWrite" ];
17
9
end
10
+ t = getPermissions(filePermissions(p ), props );
11
+ ok = any(t{: ,: }, 2 );
12
+ else
13
+ a = file_attributes_legacy(p );
14
+ ok = a .UserWrite || a .GroupWrite || a .OtherWrite ;
18
15
end
19
16
20
17
end
Original file line number Diff line number Diff line change 1
1
function a = file_attributes_legacy(p )
2
+ arguments
3
+ p {mustBeTextScalar }
4
+ end
2
5
3
6
assert(~strempty(p ), ' Path must not be empty.' )
4
7
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments