From: Jonathan Wakely Date: Wed, 4 Jul 2018 13:59:57 +0000 (+0100) Subject: Use non-throwing is_directory in filesystem::create_directory X-Git-Tag: releases/gcc-7.4.0~276 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=65215e08d3f2373803da33644d4d821095398bcb;p=thirdparty%2Fgcc.git 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. Backport from mainline 2018-03-09 Jonathan Wakely src/filesystem/ops.cc (create_dir): Pass error_code to is_directory. From-SVN: r262413 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index c0b4c5fccbac..cdd338a7b411 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,10 @@ 2018-07-04 Jonathan Wakely + Backport from mainline + 2018-03-09 Jonathan Wakely + + src/filesystem/ops.cc (create_dir): Pass error_code to is_directory. + Backport from mainline 2018-06-18 Jonathan Wakely diff --git a/libstdc++-v3/src/filesystem/ops.cc b/libstdc++-v3/src/filesystem/ops.cc index 12a87c57276c..397a8d7ffe72 100644 --- a/libstdc++-v3/src/filesystem/ops.cc +++ b/libstdc++-v3/src/filesystem/ops.cc @@ -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 {