summaryrefslogtreecommitdiff
path: root/libstdc++-v3/src/filesystem/ops.cc
diff options
context:
space:
mode:
authorredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>2016-10-24 16:45:51 +0000
committerredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>2016-10-24 16:45:51 +0000
commit10709260fa785a45441e59ceb86eb129ae3e13b1 (patch)
tree2fdbe7c11d477c3df27aa4e6f0894e21230764f5 /libstdc++-v3/src/filesystem/ops.cc
parent7650759fd5b991b1aed91849b8b596fc7c63b482 (diff)
PR71337 fix filesystem::temp_directory_path error handling
PR libstdc++/71337 * src/filesystem/ops.cc (temp_directory_path): Pass error_code argument to other filesystem operations. * testsuite/experimental/filesystem/operations/temp_directory_path.cc: Add testcase for inaccessible directory. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@241487 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/src/filesystem/ops.cc')
-rw-r--r--libstdc++-v3/src/filesystem/ops.cc13
1 files changed, 9 insertions, 4 deletions
diff --git a/libstdc++-v3/src/filesystem/ops.cc b/libstdc++-v3/src/filesystem/ops.cc
index f8ba74ecbb30..90c225b03391 100644
--- a/libstdc++-v3/src/filesystem/ops.cc
+++ b/libstdc++-v3/src/filesystem/ops.cc
@@ -1428,12 +1428,17 @@ fs::path fs::temp_directory_path(error_code& ec)
for (auto e = env; tmpdir == nullptr && *e != nullptr; ++e)
tmpdir = ::getenv(*e);
path p = tmpdir ? tmpdir : "/tmp";
- if (exists(p) && is_directory(p))
+ auto st = status(p, ec);
+ if (!ec)
{
- ec.clear();
- return p;
+ if (is_directory(st))
+ {
+ ec.clear();
+ return p;
+ }
+ else
+ ec = std::make_error_code(std::errc::not_a_directory);
}
- ec = std::make_error_code(std::errc::not_a_directory);
return {};
#endif
}