File tree Expand file tree Collapse file tree 4 files changed +16
-21
lines changed Expand file tree Collapse file tree 4 files changed +16
-21
lines changed Original file line number Diff line number Diff line change 77 p {mustBeTextScalar }
88end
99
10- r = " " ;
1110
1211try
13- [ok , t ] = isSymbolicLink(p );
14- if ~ok , return , end
12+ [ok , r ] = isSymbolicLink(p );
13+ if ~ok , r = " " ; end
1514catch e
1615 switch e .identifier
17- case " Octave:undefined-function" , t = readlink(p );
16+ case " Octave:undefined-function" , r = readlink(p );
1817 case " MATLAB:UndefinedFunction"
19- if ~stdlib .is_symlink(p )
20- return
18+ if stdlib .is_symlink(p )
19+ % must be absolute path
20+ % must not be .canonical or symlink is gobbled!
21+ r = stdlib .absolute(p , " " , false );
22+
23+ % https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/nio/file/Files.html#readSymbolicLink(java.nio.file.Path)
24+ r = java .nio .file .Files .readSymbolicLink(javaPathObject(r )).string;
25+ else
26+ r = " " ;
2127 end
22-
23- % must be absolute path
24- % must not be .canonical or symlink is gobbled!
25- r = stdlib .absolute(p , " " , false );
26-
27- % https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/nio/file/Files.html#readSymbolicLink(java.nio.file.Path)
28- t = java .nio .file .Files .readSymbolicLink(javaPathObject(r ));
2928 otherwise , rethrow(e )
3029 end
3130end
3231
33- r = stdlib .posix(t );
34-
3532end
3633
3734% !test
Original file line number Diff line number Diff line change @@ -76,7 +76,7 @@ std::string fs_read_symlink(std::string_view path)
7676#else
7777 std::error_code ec;
7878 if (auto p = std::filesystem::read_symlink (path, ec); !ec)
79- return p.generic_string ();
79+ return p.string ();
8080#endif
8181
8282 return {};
Original file line number Diff line number Diff line change @@ -137,9 +137,7 @@ std::string fs_win32_final_path(std::string_view path)
137137#else // C++98
138138 if (r.substr (0 , 4 ) == " \\\\ ?\\ " )
139139#endif
140- r = r.substr (4 );
141-
142- return fs_as_posix (r);
140+ return r.substr (4 );
143141#else
144142 return std::string (path);
145143#endif
Original file line number Diff line number Diff line change @@ -17,9 +17,9 @@ function setup_symlink(tc)
1717
1818tc.tempDir = tc .createTemporaryFolder();
1919
20- tc.link = tc .tempDir + " / my.lnk" ;
20+ tc.link = fullfile( tc .tempDir , " my.lnk" ) ;
2121
22- tc.target = stdlib .posix( mfilename(" fullpath" ) + " .m" ) ;
22+ tc.target = mfilename(" fullpath" ) + " .m" ;
2323
2424tc .assumeTrue(stdlib .create_symlink(tc .target , tc .link ), ...
2525 " failed to create test link " + tc .link )
You can’t perform that action at this time.
0 commit comments