File tree Expand file tree Collapse file tree 3 files changed +24
-12
lines changed Expand file tree Collapse file tree 3 files changed +24
-12
lines changed Original file line number Diff line number Diff line change 1+ function ok = is_symlink(p )
2+
3+ if ispc()
4+ [s , m ] = system(sprintf(' pwsh -command "(Get-Item -Path %s ).Attributes"' , p ));
5+ ok = s == 0 && contains(m , ' ReparsePoint' );
6+ else
7+ [s , ~ ] = system(sprintf(' test -L %s ' , p ));
8+ ok = s == 0 ;
9+ end
10+
11+ end
Original file line number Diff line number Diff line change 55 p {mustBeTextScalar }
66end
77
8+ if strempty(p )
9+ ok = false ;
10+ return
11+ end
12+
813try
914 ok = isSymbolicLink(p );
15+ return
1016catch e
1117 switch e .identifier
1218 case " MATLAB:UndefinedFunction"
1622 ok = java .nio .file .Files .isSymbolicLink(javaPathObject(stdlib .absolute(p )));
1723 elseif stdlib .has_python()
1824 ok = stdlib .python .is_symlink(p );
19- elseif isunix()
20- ok = system(sprintf(' test -L %s ' , p )) == 0 ;
21- elseif ispc()
22- [s , m ] = system(sprintf(' pwsh -command "(Get-Item -Path %s ).Attributes"' , p ));
23- ok = s == 0 && contains(m , ' ReparsePoint' );
2425 end
2526 case " Octave:undefined-function"
2627 % use lstat() to work with a broken symlink, like Matlab isSymbolicLink
3031 end
3132end
3233
34+ if ~ok
35+ ok = stdlib .sys .is_symlink(p );
36+ end
37+
3338end
3439
3540
Original file line number Diff line number Diff line change 77end
88
99properties (TestParameter )
10- p = init_symlink()
10+ p = {{" not-exist" , false }, ...
11+ {mfilename(" fullpath" ) + " .m" , false }, ...
12+ {" " , false }};
1113end
1214
1315
@@ -86,9 +88,3 @@ function test_create_symlink(tc)
8688end
8789end
8890
89-
90- function p = init_symlink()
91- p = {{" not-exist" , false }, ...
92- {mfilename(" fullpath" ) + " .m" , false }, ...
93- {" " , false }};
94- end
You can’t perform that action at this time.
0 commit comments