Skip to content

<filesystem>: Fix the path returned when there is an error with temp_directory_path #5570

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

YexuanXiao
Copy link
Contributor

Fix #5557.

@YexuanXiao YexuanXiao requested a review from a team as a code owner June 3, 2025 18:48
@github-project-automation github-project-automation bot moved this to Initial Review in STL Code Reviews Jun 3, 2025
@@ -4039,9 +4039,8 @@ namespace filesystem {
_STD filesystem::permissions(_Target, _Perms, perm_options::replace, _Ec);
}

_EXPORT_STD _NODISCARD inline path temp_directory_path(error_code& _Ec) {
_NODISCARD inline path _Temp_directory_path_impl(error_code& _Ec) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are advantages of wrapping the existent function instead of clearing that string on error right here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When an error occurs, _impl does not clear the path, but the error_code version does. Therefore, the exception version needs to use _impl to reuse code instead of the error_code version in order to report the path.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I see the path is the part of the exception. Then it makes sense!

@StephanTLavavej StephanTLavavej added bug Something isn't working filesystem C++17 filesystem labels Jun 3, 2025
@StephanTLavavej StephanTLavavej self-assigned this Jun 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working filesystem C++17 filesystem
Projects
Status: Initial Review
Development

Successfully merging this pull request may close these issues.

<filesystem>: temp_directory_path(error_code&) doesn't return an empty path for errors
3 participants