]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Use non-throwing is_directory in filesystem::create_directory
authorJonathan Wakely <jwakely@redhat.com>
Fri, 9 Mar 2018 01:09:58 +0000 (01:09 +0000)
committerJonathan Wakely <redi@gcc.gnu.org>
Fri, 9 Mar 2018 01:09:58 +0000 (01:09 +0000)
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

libstdc++-v3/ChangeLog
libstdc++-v3/src/filesystem/ops.cc
libstdc++-v3/src/filesystem/std-ops.cc

index 69c6ec6d29dd8952ec1d4ca00de41f104c7ad5d8..8e8fa138bfe6f0d7ceb9a99963d2b9ed92bed302 100644 (file)
@@ -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.
index 899defea6d28b20d15866f4751b49c0b71f55fac..328332a8a8295415694a679a507ac5840e83ce93 100644 (file)
@@ -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
       {
index 65b06f5b67b553c9bb4b7afbc47b5d865ea2a8dc..930b186e88ca5481e7d2f2b60d6765678dab5701 100644 (file)
@@ -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
       {