-
Notifications
You must be signed in to change notification settings - Fork 1.6k
<filesystem>: directory_entry(const path&, error_code&) should return error code
#1343
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
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I definitely agree with you. So, Because we have several tests here, here and here that expect constructing a Then the standard document explicitly says [fs.dir.entry.cons]:
So we can deduce that both This behavior appears to be correct. However, both Clang and GCC implementations do not follow this deduction! |
This comment was marked as resolved.
This comment was marked as resolved.
strega-nil-ms
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than those minor nits, I'm in favor of this change; the discussion in #232 implies to me that this is the correct way to go; having refresh() and directory_entry(const filesystem::path&) having different behavior is a bug.
The choice to make refresh() on a non-existent file succeed is, imo, the correct behavior, especially given that LLVM's libc++ makes exactly the same choice here:
_LIBCPP_INLINE_VISIBILITY
void __refresh(error_code* __ec = nullptr) {
__handle_error("in directory_entry::refresh", __ec, __do_refresh(),
/*allow_dne*/ true);
}
That seems reasonable to me.
FWIW I don't think "what libc++ does" is an arbiter of correct behavior. Not only is caching behavior intentionally not specified in the standard, what we cache is substantially different. The attributes they cache aren't different in character for existing files vs. nonexisting files which is not true for us. ================================= Don't forget to consider the other effect this does: it makes (I'm intentionally not making further statements on whether to take the change or not given that I'm no longer a maintainer and haven't been looking at this closely for a long time, only pointing out things to consider :) ) |
Co-authored-by: nicole mazzuca <83086508+strega-nil-ms@users.noreply.github.com>
This comment was marked as resolved.
This comment was marked as resolved.
|
After catching up on all of the discussion here and in #232, checking the Standard, and checking this PR's behavior, I believe that this change is correct and avoids regressing any previous fixes. I pushed a very small addition to the test coverage. Apologies for my exceptionally long review delay here! I've moved this to Final Review so Nicole can check the commits after her previous review - then we should be able to merge this next week. |
|
I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed. |
|
Thanks again for investigating and fixing this bug in the C++17 filesystem library! 📂 🐞 😻 |
|
Thank you all! |
…rn error code (microsoft#1343) Co-authored-by: Stephan T. Lavavej <stl@microsoft.com> Co-authored-by: nicole mazzuca <83086508+strega-nil-ms@users.noreply.github.com>
Fixes #232
I've tried to follow
[fs.dir.entry.cons]of the Standard document. I think there were some test cases against the Standard definition in the tests, so I have modified them. Besides the original issue, I thought the functions under[fs.dir.entry.mods]need the same fix as well.