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.
+ * src/filesystem/std-ops.cc: Likewise.
+
PR libstdc++/83279
* src/filesystem/std-ops.cc (do_copy_file): Use non-null offset with
sendfile.
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();
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
fs::remove(const path& p)
{
error_code ec;
- bool result = fs::remove(p, ec);
+ const bool result = fs::remove(p, ec);
if (ec)
_GLIBCXX_THROW_OR_ABORT(filesystem_error("cannot remove", p, ec));
return result;
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();
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