]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Use non-throwing is_directory in filesystem::create_directory
authorJonathan Wakely <jwakely@redhat.com>
Wed, 4 Jul 2018 13:59:57 +0000 (14:59 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Wed, 4 Jul 2018 13:59:57 +0000 (14:59 +0100)
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.

Backport from mainline
2018-03-09  Jonathan Wakely  <jwakely@redhat.com>

src/filesystem/ops.cc (create_dir): Pass error_code to is_directory.

From-SVN: r262413

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

index c0b4c5fccbacf40bcfd9e0d52cb207275f670f12..cdd338a7b411d43f2192673068592793d9d6df10 100644 (file)
@@ -1,5 +1,10 @@
 2018-07-04  Jonathan Wakely  <jwakely@redhat.com>
 
+       Backport from mainline
+       2018-03-09  Jonathan Wakely  <jwakely@redhat.com>
+
+       src/filesystem/ops.cc (create_dir): Pass error_code to is_directory.
+
        Backport from mainline
        2018-06-18  Jonathan Wakely  <jwakely@redhat.com>
 
index 12a87c57276cba7a291abc3035ec2066cbf0d3cc..397a8d7ffe72b96b7d7163f5919da9f7126a7f82 100644 (file)
@@ -720,10 +720,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
       {