]> git.ipfire.org Git - thirdparty/gcc.git/commit
libstdc++: Improve exceptions thrown from fs::temp_directory_path
authorJonathan Wakely <jwakely@redhat.com>
Tue, 28 Jun 2022 15:09:21 +0000 (16:09 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Thu, 30 Jun 2022 13:16:27 +0000 (14:16 +0100)
commit1eef21ccfa5988a23a3b71a99613f27ea6a26da6
tree144bbcd52978c765c87546bcfbe758a8253c5271
parent6c96b14a19a9e6c365eacc59868a866b99f9786d
libstdc++: Improve exceptions thrown from fs::temp_directory_path

Currently the throwing overload of fs::temp_directory_path() will
discard the path that was obtained from the environment. When it fails
because the path doesn't resolve to a directory you get an unhelpful
error like:

  filesystem error: temp_directory_path: Not a directory

It would be better to also print the path in that case, e.g.

  filesystem error: temp_directory_path: Not a directory [/home/bob/tmp]

libstdc++-v3/ChangeLog:

* src/c++17/fs_ops.cc (fs::temp_directory_path()): Include path
in exception.
(fs::temp_directory_path(error_code&)): Rearrange to more
closely match the structure of the first overload.
* src/filesystem/ops.cc (fs::temp_directory_path): Likewise.
* testsuite/27_io/filesystem/operations/temp_directory_path.cc:
Check that exception contains the path.
* testsuite/experimental/filesystem/operations/temp_directory_path.cc:
Likewise.
libstdc++-v3/src/c++17/fs_ops.cc
libstdc++-v3/src/filesystem/ops.cc
libstdc++-v3/testsuite/27_io/filesystem/operations/temp_directory_path.cc
libstdc++-v3/testsuite/experimental/filesystem/operations/temp_directory_path.cc