File tree Expand file tree Collapse file tree 7 files changed +32
-23
lines changed Expand file tree Collapse file tree 7 files changed +32
-23
lines changed Original file line number Diff line number Diff line change 2121 return
2222end
2323
24- if stdlib .isoctave() || isMATLABReleaseOlderThan(' R2024a' )
25- c = acanon(p );
26- else
24+ try
2725 pth = matlab .io .internal .filesystem .resolvePath(p );
2826 c = pth .ResolvedPath ;
2927 if strempty(c )
3028 c = stdlib .normalize(p );
3129 end
30+ catch e
31+ switch e .identifier
32+ case {' MATLAB:UndefinedFunction' , ' Octave:undefined-function' }, c = acanon(p );
33+ otherwise , rethrow(e )
34+ end
3235end
3336
3437try % #ok<*TRYNC>
Original file line number Diff line number Diff line change 1414 if err == 0
1515 i = s .ino ;
1616 end
17- elseif isunix() && stdlib .has_java() && stdlib . java_api() >= 11
17+ elseif isunix() && stdlib .java_api() >= 11
1818 % Java 1.8 is buggy in some corner cases, so we require at least 11.
1919 i = java .nio .file .Files .getAttribute(javaPathObject(path ), " unix:ino" , javaLinkOption());
2020end
Original file line number Diff line number Diff line change 88end
99% need to have string array type for p(:)
1010
11- if ~ stdlib .isoctave() && ~isMATLABReleaseOlderThan( ' R2025a ' )
11+ try
1212 if isunix
1313 props = [" UserExecute" , " GroupExecute" , " OtherExecute" ];
1414 else
1515 props = " Readable" ;
1616 end
1717 t = getPermissions(filePermissions(p ), props );
1818 ok = isfile(p(: )) & any(t{: ,: }, 2 );
19- else
20- a = file_attributes_legacy(p );
21- ok = isfile(p ) && (a .UserExecute || a .GroupExecute || a .OtherExecute );
19+ catch e
20+ switch e .identifier
21+ case {' MATLAB:UndefinedFunction' , ' Octave:undefined-function' }
22+ a = file_attributes_legacy(p );
23+ ok = isfile(p ) && (a .UserExecute || a .GroupExecute || a .OtherExecute );
24+ otherwise , rethrow(e )
25+ end
2226end
2327
2428end
Original file line number Diff line number Diff line change 22
33function ok = is_readable(p )
44
5- if ~ stdlib .isoctave() && ~isMATLABReleaseOlderThan( ' R2025a ' )
5+ try
66 props = " Readable" ;
77 if isunix
88 props = [props , " GroupRead" , " OtherRead" ];
99 end
1010 t = getPermissions(filePermissions(p ), props );
1111 ok = any(t{: ,: }, 2 );
12- else
13- a = file_attributes_legacy(p );
14- ok = a .UserRead || a .GroupRead || a .OtherRead ;
12+ catch e
13+ switch e .identifier
14+ case {' MATLAB:UndefinedFunction' , ' Octave:undefined-function' }
15+ a = file_attributes_legacy(p );
16+ ok = a .UserRead || a .GroupRead || a .OtherRead ;
17+ otherwise , rethrow(e )
18+ end
1519end
1620
21+ end
1722% !assert (is_readable('is_readable.m'))
Original file line number Diff line number Diff line change 22% optional: mex
33
44function ok = is_symlink(p )
5- arguments
6- p {mustBeTextScalar }
7- end
8-
95
106try
117 ok = isSymbolicLink(p );
Original file line number Diff line number Diff line change 22% e.g. https://example.invalid is true
33
44function y = is_url(s )
5- arguments
6- s {mustBeTextScalar }
7- end
85
96y = startsWith(s , alphanumericsPattern + " ://" );
107
Original file line number Diff line number Diff line change 22
33function ok = is_writable(p )
44
5- if ~ stdlib .isoctave() && ~isMATLABReleaseOlderThan( ' R2025a ' )
5+ try
66 props = " Writable" ;
77 if isunix
88 props = [props , " GroupWrite" , " OtherWrite" ];
99 end
1010 t = getPermissions(filePermissions(p ), props );
1111 ok = any(t{: ,: }, 2 );
12- else
13- a = file_attributes_legacy(p );
14- ok = a .UserWrite || a .GroupWrite || a .OtherWrite ;
12+ catch e
13+ switch e .identifier
14+ case {' MATLAB:UndefinedFunction' , ' Octave:undefined-function' }
15+ a = file_attributes_legacy(p );
16+ ok = a .UserWrite || a .GroupWrite || a .OtherWrite ;
17+ otherwise , rethrow(e )
18+ end
1519end
1620
1721end
You can’t perform that action at this time.
0 commit comments