aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2018-03-09 01:09:58 +0000
committerJonathan Wakely <redi@gcc.gnu.org>2018-03-09 01:09:58 +0000
commit311735dbc6783b8669850b0b882834bd41a4e1f1 (patch)
tree8501e89c1ac01bf8dd5824c58c4140fc0e204e54
parent0bfd8ca928bacfe66700b28976c903d1fe46fbe5 (diff)
downloadgcc-311735dbc6783b8669850b0b882834bd41a4e1f1.zip
gcc-311735dbc6783b8669850b0b882834bd41a4e1f1.tar.gz
gcc-311735dbc6783b8669850b0b882834bd41a4e1f1.tar.bz2
Use non-throwing is_directory in filesystem::create_directory
The create_dir helper was calling the throwing form of filesystem::is_directory instead of passing the error_code argument. Since std::filesystem::create_directory(const path&, error_code&) is noexcept, it would call std::terminate if an error occurred in is_directory. Passing the error_code also takes care of clearing it in the case where is_directory returns true. src/filesystem/ops.cc (create_dir): Pass error_code to is_directory. src/filesystem/std-ops.cc (create_dir): Likewise. From-SVN: r258375
-rw-r--r--libstdc++-v3/ChangeLog5
-rw-r--r--libstdc++-v3/src/filesystem/ops.cc4
-rw-r--r--libstdc++-v3/src/filesystem/std-ops.cc4
3 files changed, 7 insertions, 6 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 69c6ec6..8e8fa13 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,8 @@
+2018-03-09 Jonathan Wakely <jwakely@redhat.com>
+
+ src/filesystem/ops.cc (create_dir): Pass error_code to is_directory.
+ src/filesystem/std-ops.cc (create_dir): Likewise.
+
2018-03-08 François Dumont <fdumont@gcc.gnu.org>
* python/libstdcxx/v6/printers.py (NodeIteratorPrinter): New.
diff --git a/libstdc++-v3/src/filesystem/ops.cc b/libstdc++-v3/src/filesystem/ops.cc
index 899defe..328332a8a 100644
--- a/libstdc++-v3/src/filesystem/ops.cc
+++ b/libstdc++-v3/src/filesystem/ops.cc
@@ -463,10 +463,8 @@ namespace
if (::mkdir(p.c_str(), mode))
{
const int err = errno;
- if (err != EEXIST || !is_directory(p))
+ if (err != EEXIST || !is_directory(p, ec))
ec.assign(err, std::generic_category());
- else
- ec.clear();
}
else
{
diff --git a/libstdc++-v3/src/filesystem/std-ops.cc b/libstdc++-v3/src/filesystem/std-ops.cc
index 65b06f5..930b186 100644
--- a/libstdc++-v3/src/filesystem/std-ops.cc
+++ b/libstdc++-v3/src/filesystem/std-ops.cc
@@ -668,10 +668,8 @@ namespace
if (::mkdir(p.c_str(), mode))
{
const int err = errno;
- if (err != EEXIST || !is_directory(p))
+ if (err != EEXIST || !is_directory(p, ec))
ec.assign(err, std::generic_category());
- else
- ec.clear();
}
else
{