mirror of
https://github.com/gulrak/filesystem.git
synced 2026-09-14 14:52:15 +08:00
Merge 1443c5a37eb062d75843eb91a2cfaf4d10ccdb55 into 2b4d7f239e0e749315fca1de7b2cf7438cf94a9a
This commit is contained in:
commit
5e8aa36b0e
@ -4085,7 +4085,9 @@ GHC_INLINE void copy_symlink(const path& existing_symlink, const path& new_symli
|
||||
ec.clear();
|
||||
auto to = read_symlink(existing_symlink, ec);
|
||||
if (!ec) {
|
||||
if (exists(to, ec) && is_directory(to, ec)) {
|
||||
// Relative targets are relative to the source link parent (#211).
|
||||
path lookup = to.is_absolute() ? to : (existing_symlink.parent_path() / to);
|
||||
if (exists(lookup, ec) && is_directory(lookup, ec)) {
|
||||
create_directory_symlink(to, new_symlink, ec);
|
||||
}
|
||||
else {
|
||||
|
||||
@ -1918,6 +1918,18 @@ TEST_CASE("fs.op.copy_symlink - copy_symlink", "[filesystem][operations][fs.op.c
|
||||
CHECK_NOTHROW(fs::copy_symlink("sdir", "sdirc2", ec));
|
||||
CHECK(fs::exists("sdirc2"));
|
||||
CHECK(!ec);
|
||||
|
||||
// Relative targets must be resolved against the source link parent
|
||||
// (not cwd) when classifying directory vs file links on Windows.
|
||||
fs::create_directories("nested/dir");
|
||||
fs::create_directory_symlink("dir", "nested/slink");
|
||||
CHECK_NOTHROW(fs::copy_symlink("nested/slink", "nested/slink_copy"));
|
||||
CHECK(fs::read_symlink("nested/slink_copy") == "dir");
|
||||
CHECK(fs::is_directory("nested/slink_copy"));
|
||||
CHECK_NOTHROW(fs::copy_symlink("nested/slink", "nested/slink_copy2", ec));
|
||||
CHECK(!ec);
|
||||
CHECK(fs::read_symlink("nested/slink_copy2") == "dir");
|
||||
CHECK(fs::is_directory("nested/slink_copy2"));
|
||||
}
|
||||
CHECK_THROWS_AS(fs::copy_symlink("bar", "barc"), fs::filesystem_error);
|
||||
CHECK_NOTHROW(fs::copy_symlink("bar", "barc", ec));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user