File tree Expand file tree Collapse file tree 12 files changed +89
-78
lines changed Expand file tree Collapse file tree 12 files changed +89
-78
lines changed Original file line number Diff line number Diff line change 11function a = file_attributes(p )
2- arguments
3- p {mustBeTextScalar }
4- end
52
63assert(~stdlib .strempty(p ), ' Path must not be empty.' )
74
Original file line number Diff line number Diff line change 1- function y = is_exe(p )
1+ function y = is_exe(file )
22
3- y = isfile(p );
3+ y = isfile(file );
44
55if ispc()
6- y = y && stdlib .native .has_windows_executable_suffix(p );
6+ y = y && stdlib .native .has_windows_executable_suffix(file );
77end
88
99if ~y , return , end
1010
11-
12- if ~isMATLABReleaseOlderThan(' R2025a' )
13-
14- if isunix
15- props = [" UserExecute" , " GroupExecute" , " OtherExecute" ];
16- else
17- props = " Readable" ;
18- end
19-
20- t = getPermissions(filePermissions(p ), props );
21-
22- y = any(t{1 , : });
23-
11+ if isunix
12+ props = [" UserExecute" , " GroupExecute" , " OtherExecute" ];
2413else
14+ props = " Readable" ;
15+ end
2516
26- a = stdlib .native .file_attributes(p );
27- y = a .UserExecute || a .GroupExecute || a .OtherExecute ;
17+ t = getPermissions(filePermissions(file ), props );
2818
29- end
19+ y = any(t{ 1 , : });
3020
3121end
Original file line number Diff line number Diff line change 1+ function y = is_exe_legacy(file )
2+
3+ y = isfile(file );
4+
5+ if ispc()
6+ y = y && stdlib .native .has_windows_executable_suffix(file );
7+ end
8+
9+ if ~y , return , end
10+
11+ a = stdlib .native .file_attributes(file );
12+ y = a .UserExecute || a .GroupExecute || a .OtherExecute ;
13+
14+ end
Original file line number Diff line number Diff line change 1- function y = is_readable(p )
1+ function y = is_readable(file )
22
33y = false ;
44
5- if ~stdlib .exists(p ), return , end
6-
7- if ~isMATLABReleaseOlderThan(' R2025a' )
8-
9- props = " Readable" ;
10- if isunix
11- props = [props , " GroupRead" , " OtherRead" ];
12- end
13-
14- t = getPermissions(filePermissions(p ), props );
15- y = any(t{1 , : });
16-
17- else
18-
19- a = stdlib .native .file_attributes(p );
20- y = a .UserRead || a .GroupRead || a .OtherRead ;
5+ if ~stdlib .exists(file ), return , end
216
7+ props = " Readable" ;
8+ if isunix
9+ props = [props , " GroupRead" , " OtherRead" ];
2210end
2311
12+ t = getPermissions(filePermissions(file ), props );
13+ y = any(t{1 , : });
14+
2415end
Original file line number Diff line number Diff line change 1+ function y = is_readable_legacy(file )
2+
3+ if stdlib .exists(file )
4+ a = stdlib .native .file_attributes(file );
5+ y = a .UserRead || a .GroupRead || a .OtherRead ;
6+ else
7+ y = false ;
8+ end
9+
10+ end
Original file line number Diff line number Diff line change 44
55if ~stdlib .exists(p ), return , end
66
7- if ~isMATLABReleaseOlderThan(' R2025a' )
8-
9- props = " Writable" ;
10- if isunix
11- props = [props , " GroupWrite" , " OtherWrite" ];
12- end
7+ props = " Writable" ;
8+ if isunix
9+ props = [props , " GroupWrite" , " OtherWrite" ];
10+ end
1311
14- t = getPermissions(filePermissions(p ), props );
15- y = any(t{1 , : });
12+ t = getPermissions(filePermissions(p ), props );
13+ y = any(t{1 , : });
1614
17- else
18- a = stdlib .native .file_attributes(p );
19- y = a .UserWrite || a .GroupWrite || a .OtherWrite ;
2015end
21-
22- end
Original file line number Diff line number Diff line change 1+ function y = is_writable_legacy(file )
2+
3+ if stdlib .exists(file )
4+ a = stdlib .native .file_attributes(file );
5+ y = a .UserWrite || a .GroupWrite || a .OtherWrite ;
6+ else
7+ y = false ;
8+ end
9+
10+ end
Original file line number Diff line number Diff line change 11%% IS_READABLE is file readable
22%
33% %% Inputs
4- % p: string array of file paths
4+ % file: single path string
55%% Outputs
6- % ok: logical array of the same size as p, true if file is readable
6+ % ok: true if file is readable
77
8- function y = is_readable(p )
8+ function y = is_readable(file )
99arguments
10- p {mustBeTextScalar }
10+ file {mustBeTextScalar }
1111end
1212
1313if stdlib .has_java()
14- y = stdlib .java .is_readable(p );
14+ y = stdlib .java .is_readable(file );
15+ elseif isMATLABReleaseOlderThan(' R2025a' )
16+ y = stdlib .native .is_readable_legacy(file );
1517else
16- y = stdlib .native .is_readable(p );
18+ y = stdlib .native .is_readable(file );
1719end
1820
19-
2021end
Original file line number Diff line number Diff line change 11%% IS_WRITABLE is path writable
22%
33% %% Inputs
4- % p: string array of file paths
4+ % file: path to file or folder
55%% Outputs
6- % ok: logical array of the same size as p, true if file is writable
6+ % ok: true if file is writable
77
8- function y = is_writable(p )
8+ function y = is_writable(file )
99arguments
10- p {mustBeTextScalar }
10+ file {mustBeTextScalar }
1111end
1212
1313if stdlib .has_java()
14- y = stdlib .java .is_writable(p );
14+ y = stdlib .java .is_writable(file );
15+ elseif isMATLABReleaseOlderThan(' R2025a' )
16+ y = stdlib .native .is_writable_legacy(file );
1517else
16- y = stdlib .native .is_writable(p );
18+ y = stdlib .native .is_writable(file );
1719end
1820
1921end
Original file line number Diff line number Diff line change 11%% PROXIMATE_TO relative path to base
22%
33% %% Inputs
4- % * base {mustBeTextScalar}
5- % * other {mustBeTextScalar}
4+ % * base: directory to which the other path should be relative
5+ % * other: path to be made relative
66% %% Outputs
7- % * rel {mustBeTextScalar}
7+ % * rel: relative path from base to other
88
99function rel = proximate_to(base , other )
10- arguments
11- base {mustBeTextScalar }
12- other {mustBeTextScalar }
13- end
1410
1511rel = stdlib .relative_to(base , other );
1612if stdlib .strempty(rel )
You can’t perform that action at this time.
0 commit comments