PR libstdc++/83626 simplify filesystem::remove and filesystem::remove_all

Backport from mainline
2018-01-05  Jonathan Wakely  <jwakely@redhat.com>

	PR libstdc++/83626
	* src/filesystem/ops.cc (remove(const path&, error_code&)): Remove
	unnecessary symlink_status call.
	(remove_all(const path&, error_code&)): Use filesystem::remove.

From-SVN: r256603
This commit is contained in:
Jonathan Wakely 2018-01-13 01:53:47 +00:00 committed by Jonathan Wakely
parent ab1c0a5d9c
commit b520d0cffb
2 changed files with 12 additions and 15 deletions

View File

@ -1,3 +1,13 @@
2018-01-13 Jonathan Wakely <jwakely@redhat.com>
Backport from mainline
2018-01-05 Jonathan Wakely <jwakely@redhat.com>
PR libstdc++/83626
* src/filesystem/ops.cc (remove(const path&, error_code&)): Remove
unnecessary symlink_status call.
(remove_all(const path&, error_code&)): Use filesystem::remove.
2018-01-05 Jonathan Wakely <jwakely@redhat.com>
Backport from mainline

View File

@ -1274,14 +1274,6 @@ fs::remove(const path& p)
bool
fs::remove(const path& p, error_code& ec) noexcept
{
const auto s = symlink_status(p, ec);
if (!status_known(s))
return false;
if (s.type() == file_type::not_found)
{
ec.clear();
return false; // Nothing to do, not an error.
}
if (::remove(p.c_str()) == 0)
{
ec.clear();
@ -1327,14 +1319,9 @@ fs::remove_all(const path& p, error_code& ec) noexcept
return -1;
}
if (::remove(p.c_str()) == 0)
if (fs::remove(p, ec))
++count;
else if (errno != ENOENT)
{
ec.assign(errno, std::generic_category());
return -1;
}
return count;
return ec ? -1 : count;
}
void