aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2018-01-05 23:51:22 +0000
committerJonathan Wakely <redi@gcc.gnu.org>2018-01-05 23:51:22 +0000
commit4ca07db039fbf0bf9b024e1b1645667939c1194e (patch)
treea646854c4baf6436ee417940f6aea54ec253a09e
parent2526c53acf9e80a917f157b527e3d4806208f230 (diff)
downloadgcc-4ca07db039fbf0bf9b024e1b1645667939c1194e.zip
gcc-4ca07db039fbf0bf9b024e1b1645667939c1194e.tar.gz
gcc-4ca07db039fbf0bf9b024e1b1645667939c1194e.tar.bz2
PR libstdc++/83626 simplify filesystem::remove and filesystem::remove_all
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. From-SVN: r256301
-rw-r--r--libstdc++-v3/ChangeLog6
-rw-r--r--libstdc++-v3/src/filesystem/ops.cc17
-rw-r--r--libstdc++-v3/src/filesystem/std-ops.cc19
3 files changed, 11 insertions, 31 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 444c615..b074111 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,5 +1,11 @@
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.
diff --git a/libstdc++-v3/src/filesystem/ops.cc b/libstdc++-v3/src/filesystem/ops.cc
index 3690fb9..899defe 100644
--- a/libstdc++-v3/src/filesystem/ops.cc
+++ b/libstdc++-v3/src/filesystem/ops.cc
@@ -1017,14 +1017,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();
@@ -1070,14 +1062,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
diff --git a/libstdc++-v3/src/filesystem/std-ops.cc b/libstdc++-v3/src/filesystem/std-ops.cc
index bed1ad1..65b06f5 100644
--- a/libstdc++-v3/src/filesystem/std-ops.cc
+++ b/libstdc++-v3/src/filesystem/std-ops.cc
@@ -1254,7 +1254,7 @@ bool
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;
@@ -1263,14 +1263,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();
@@ -1316,14 +1308,9 @@ fs::remove_all(const path& p, error_code& ec)
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