-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
bugSomething isn't workingSomething isn't workingfilesystemC++17 filesystemC++17 filesystemfixedSomething works now, yay!Something works now, yay!
Description
Lines 2106 to 2109 in d736fe4
| directory_entry(const filesystem::path& _Path_arg, error_code& _Ec) : _Cached_data{}, _Path(_Path_arg) { | |
| _Ec.clear(); | |
| (void) _Refresh(_Cached_data, _Path); | |
| } |
Notice the _Ec is cleared but never assigned the return value of _Refresh(). Compare this with:
Lines 2147 to 2149 in d736fe4
| void refresh(error_code& _Ec) noexcept { | |
| _Ec = _Make_ec(_Refresh(_Cached_data, _Path)); | |
| } |
This is at best inconsistent with calling std::directory_entry::refresh( std::error_code& ec) but I would argue that it's the constructor that's wrong.
This can be easily tested by giving these two methods the same non-existent file path. The expected behaviour is that both of these methods return the same error_code value. i.e. NOT having the constructor form return success for an error code, but then calling refresh() returns a failure error code.
Sample test code
// compile with: cl /std:c++17 /permissive- /EHsc /Od /Zi symlink.cpp
// run: .\symlink does_not_exist
//
#include <filesystem>
#include <iostream>
namespace fs = std::filesystem;
int main(int argc, const char* argv[])
{
if (argc < 2)
{
std::cerr << "Missing file path argument\n";
return -1;
}
fs::path dst(argv[1]);
std::error_code err1;
fs::directory_entry src(dst, err1);
std::cout << "directory_entry(" << dst << ") = " << err1 << " " << err1.message() << "\n";
std::error_code err2;
src.refresh(err2);
std::cout << "refresh(" << dst << ") = " << err2 << " " << err2.message() << "\n";
return 0;
}
Also tracked by Microsoft-internal VSO-1012326 / AB#1012326.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingfilesystemC++17 filesystemC++17 filesystemfixedSomething works now, yay!Something works now, yay!