File tree Expand file tree Collapse file tree 10 files changed +35
-26
lines changed Expand file tree Collapse file tree 10 files changed +35
-26
lines changed Original file line number Diff line number Diff line change 21
21
return
22
22
end
23
23
24
- if stdlib .isoctave() || isMATLABReleaseOlderThan(' R2024a' )
25
- c = acanon(p );
26
- else
24
+ try
27
25
pth = matlab .io .internal .filesystem .resolvePath(p );
28
26
c = pth .ResolvedPath ;
29
27
if strempty(c )
30
28
c = stdlib .normalize(p );
31
29
end
30
+ catch e
31
+ switch e .identifier
32
+ case {' MATLAB:undefinedVarOrClass' , ' Octave:undefined-function' }, c = acanon(p );
33
+ otherwise , rethrow(e )
34
+ end
32
35
end
33
36
34
37
try % #ok<*TRYNC>
Original file line number Diff line number Diff line change 14
14
if err == 0
15
15
i = s .dev ;
16
16
end
17
- elseif isunix() && stdlib .has_java() && stdlib . java_api() >= 11
17
+ elseif isunix() && stdlib .java_api() >= 11
18
18
% Java 1.8 is buggy in some corner cases, so we require at least 11.
19
19
i = java .nio .file .Files .getAttribute(javaPathObject(path ), " unix:dev" , javaLinkOption());
20
20
end
Original file line number Diff line number Diff line change 17
17
if err == 0
18
18
c = s .nlink ;
19
19
end
20
- elseif isunix() && stdlib .has_java()
20
+ elseif isunix()
21
21
c = java .nio .file .Files .getAttribute(javaPathObject(p ), " unix:nlink" , javaLinkOption());
22
22
end
23
23
Original file line number Diff line number Diff line change 14
14
if err == 0
15
15
i = s .ino ;
16
16
end
17
- elseif isunix() && stdlib .has_java() && stdlib . java_api() >= 11
17
+ elseif isunix() && stdlib .java_api() >= 11
18
18
% Java 1.8 is buggy in some corner cases, so we require at least 11.
19
19
i = java .nio .file .Files .getAttribute(javaPathObject(path ), " unix:ino" , javaLinkOption());
20
20
end
Original file line number Diff line number Diff line change 8
8
end
9
9
% need to have string array type for p(:)
10
10
11
- if ~ stdlib .isoctave() && ~isMATLABReleaseOlderThan( ' R2025a ' )
11
+ try
12
12
if isunix
13
13
props = [" UserExecute" , " GroupExecute" , " OtherExecute" ];
14
14
else
15
15
props = " Readable" ;
16
16
end
17
17
t = getPermissions(filePermissions(p ), props );
18
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 );
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
22
26
end
23
27
24
28
end
Original file line number Diff line number Diff line change 2
2
3
3
function ok = is_readable(p )
4
4
5
- if ~ stdlib .isoctave() && ~isMATLABReleaseOlderThan( ' R2025a ' )
5
+ try
6
6
props = " Readable" ;
7
7
if isunix
8
8
props = [props , " GroupRead" , " OtherRead" ];
9
9
end
10
10
t = getPermissions(filePermissions(p ), props );
11
11
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
15
19
end
16
20
21
+ end
17
22
% !assert (is_readable('is_readable.m'))
Original file line number Diff line number Diff line change 2
2
% optional: mex
3
3
4
4
function ok = is_symlink(p )
5
- arguments
6
- p {mustBeTextScalar }
7
- end
8
-
9
5
10
6
try
11
7
ok = isSymbolicLink(p );
Original file line number Diff line number Diff line change 2
2
% e.g. https://example.invalid is true
3
3
4
4
function y = is_url(s )
5
- arguments
6
- s {mustBeTextScalar }
7
- end
8
5
9
6
y = startsWith(s , alphanumericsPattern + " ://" );
10
7
Original file line number Diff line number Diff line change 2
2
3
3
function ok = is_writable(p )
4
4
5
- if ~ stdlib .isoctave() && ~isMATLABReleaseOlderThan( ' R2025a ' )
5
+ try
6
6
props = " Writable" ;
7
7
if isunix
8
8
props = [props , " GroupWrite" , " OtherWrite" ];
9
9
end
10
10
t = getPermissions(filePermissions(p ), props );
11
11
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
15
19
end
16
20
17
21
end
Original file line number Diff line number Diff line change @@ -77,7 +77,7 @@ function test_java_version(tc)
77
77
78
78
function test_java_api(tc )
79
79
v = stdlib .java_api();
80
- tc .verifyGreaterThanOrEqual (v , 8 , " Java API >= 8 is required for Matlab-stdlib" )
80
+ tc .assertGreaterThanOrEqual (v , 8 , " Java API >= 8 is required for Matlab-stdlib" )
81
81
end
82
82
83
83
function test_cpu_arch(tc )
You can’t perform that action at this time.
0 commit comments