Implement LWG 2681 and 2682

llvm-svn: 284316
This commit is contained in:
Eric Fiselier 2016-10-16 00:29:22 +00:00
parent 736538b0fc
commit ae4c3e1699
3 changed files with 48 additions and 4 deletions

View File

@ -236,6 +236,9 @@ void __copy(const path& from, const path& to, copy_options options,
}
return;
}
else if (is_directory(f) && bool(copy_options::create_symlinks & options)) {
return set_or_throw(make_error_code(errc::is_a_directory), ec, "copy");
}
else if (is_directory(f) && (bool(copy_options::recursive & options) ||
copy_options::none == options)) {

View File

@ -257,6 +257,47 @@ TEST_CASE(from_is_directory)
}
}
TEST_CASE(test_copy_symlinks_to_symlink_dir)
{
scoped_test_env env;
const path file1 = env.create_file("file1", 42);
const path file2 = env.create_file("file2", 101);
const path file2_sym = env.create_symlink(file2, "file2_sym");
const path dir = env.create_dir("dir");
const path dir_sym = env.create_symlink(dir, "dir_sym");
{
std::error_code ec = GetTestEC();
fs::copy(file1, dir_sym, copy_options::copy_symlinks, ec);
TEST_CHECK(!ec);
const path dest = env.make_env_path("dir/file1");
TEST_CHECK(exists(dest));
TEST_CHECK(!is_symlink(dest));
TEST_CHECK(file_size(dest) == 42);
}
}
TEST_CASE(test_dir_create_symlink)
{
scoped_test_env env;
const path dir = env.create_dir("dir1");
const path dest = env.make_env_path("dne");
{
std::error_code ec = GetTestEC();
fs::copy(dir, dest, copy_options::create_symlinks, ec);
TEST_CHECK(ec == std::make_error_code(std::errc::is_a_directory));
TEST_CHECK(!exists(dest));
TEST_CHECK(!is_symlink(dest));
}
{
std::error_code ec = GetTestEC();
fs::copy(dir, dest, copy_options::create_symlinks|copy_options::recursive, ec);
TEST_CHECK(ec == std::make_error_code(std::errc::is_a_directory));
TEST_CHECK(!exists(dest));
TEST_CHECK(!is_symlink(dest));
}
}
TEST_CASE(test_otherwise_no_effects_clause)
{
scoped_test_env env;

View File

@ -94,8 +94,8 @@
<tr><td><a href="http://wg21.link/LWG2678">2678</a></td><td>std::filesystem enum classes overspecified</td><td>Issaquah</td><td>Nothing to do</td></tr>
<tr><td><a href="http://wg21.link/LWG2679">2679</a></td><td>Inconsistent Use of Effects and Equivalent To</td><td>Issaquah</td><td>Nothing to do</td></tr>
<tr><td><a href="http://wg21.link/LWG2680">2680</a></td><td>Add "Equivalent to" to filesystem</td><td>Issaquah</td><td>Nothing to do</td></tr>
<tr><td><a href="http://wg21.link/LWG2681">2681</a></td><td>filesystem::copy() cannot copy symlinks</td><td>Issaquah</td><td></td></tr>
<tr><td><a href="http://wg21.link/LWG2682">2682</a></td><td>filesystem::copy() won't create a symlink to a directory</td><td>Issaquah</td><td></td></tr>
<tr><td><a href="http://wg21.link/LWG2681">2681</a></td><td>filesystem::copy() cannot copy symlinks</td><td>Issaquah</td><td>We already do this</td></tr>
<tr><td><a href="http://wg21.link/LWG2682">2682</a></td><td>filesystem::copy() won't create a symlink to a directory</td><td>Issaquah</td><td>Implemented in trunk</td></tr>
<tr><td><a href="http://wg21.link/LWG2686">2686</a></td><td>Why is std::hash specialized for error_code, but not error_condition?</td><td>Issaquah</td><td>Patch ready</td></tr>
<tr><td><a href="http://wg21.link/LWG2694">2694</a></td><td>Application of LWG 436 accidentally deleted definition of "facet"</td><td>Issaquah</td><td>Nothing to do</td></tr>
<tr><td><a href="http://wg21.link/LWG2696">2696</a></td><td>Interaction between make_shared and enable_shared_from_this is underspecified</td><td>Issaquah</td><td></td></tr>
@ -172,8 +172,8 @@
<li>2678 - File System; Eric?</li>
<li>2679 - This is just wording cleanup. </li>
<li>2680 - This is just wording cleanup. </li>
<li>2681 - File System; Eric?</li>
<li>2682 - File System; Eric?</li>
<li>2681 - LGTM </li>
<li>2682 - Current PR is incorrect. A modified version has been implemented</li>
<li>2686 - Patch and tests ready</li>
<li>2694 - Restoring inadvertently deleted text. No code changes needed.</li>
<li>2696 - I <b>suspect</b> that this is just better specification of the existing structure. Probably need more tests for this.</li>