File tree Expand file tree Collapse file tree 1 file changed +23
-8
lines changed Expand file tree Collapse file tree 1 file changed +23
-8
lines changed Original file line number Diff line number Diff line change 1111 switch e .identifier
1212 case " MATLAB:UndefinedFunction"
1313 if stdlib .has_dotnet()
14- if stdlib .dotnet_api() >= 6
15- ok = ~isempty(System .IO .FileInfo(p ).LinkTarget);
16- else
17- attr = string(System .IO .File .GetAttributes(p ).ToString());
18- % https://learn.microsoft.com/en-us/dotnet/api/system.io.fileattributes
19- % ReparsePoint is for Linux, macOS, and Windows
20- ok = contains(attr , ' ReparsePoint' );
21- end
14+ ok = is_symlink_dotnet(p );
2215 elseif stdlib .has_java()
2316 ok = java .nio .file .Files .isSymbolicLink(javaPathObject(stdlib .absolute(p )));
2417 elseif stdlib .has_python()
3730end
3831
3932
33+ function y = is_symlink_dotnet(p )
34+
35+ try
36+ if stdlib .dotnet_api() >= 6
37+ y = ~isempty(System .IO .FileInfo(p ).LinkTarget);
38+ else
39+ attr = string(System .IO .File .GetAttributes(p ).ToString());
40+ % https://learn.microsoft.com/en-us/dotnet/api/system.io.fileattributes
41+ % ReparsePoint is for Linux, macOS, and Windows
42+ y = contains(attr , ' ReparsePoint' );
43+ end
44+ catch e
45+ switch e .identifier
46+ case {' MATLAB:NET:CLRException:CreateObject' , ' MATLAB:NET:CLRException:MethodInvoke' }
47+ y = false ;
48+ otherwise , rethrow(e )
49+ end
50+ end
51+
52+ end
53+
54+
4055% !test
4156% ! if !ispc
4257% ! p = tempname();
You can’t perform that action at this time.
0 commit comments