Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions stl/inc/filesystem
Original file line number Diff line number Diff line change
Expand Up @@ -2469,6 +2469,14 @@ namespace filesystem {
return _Path >= _Rhs._Path;
}

// [fs.dir.entry.io], inserter
template <class _Elem, class _Traits>
friend _STD basic_ostream<_Elem, _Traits>& operator<<( // TRANSITION, VSO-570323
_STD basic_ostream<_Elem, _Traits>& _Ostr, const directory_entry& _Entry) { // TRANSITION, VSO-570323
// insert a directory_entry into a stream
return _Ostr << _Entry.path();
}

private:
void _Refresh(const __std_fs_find_data& _Data) noexcept {
_Cached_data._Attributes = _Data._Attributes;
Expand Down
15 changes: 13 additions & 2 deletions tests/std/tests/P0218R1_filesystem/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1224,6 +1224,12 @@ void test_directory_entry() {
EXPECT(good(ec));
remove(dirPath, ec);
EXPECT(good(ec));

// LWG-3171 "LWG-2989 breaks directory_entry stream insertion"
const directory_entry iostreamEntry{path{R"(one\two\three)"}};
ostringstream oss;
oss << iostreamEntry;
EXPECT(oss.str() == R"("one\\two\\three")");
}

template <typename DirectoryIterator>
Expand Down Expand Up @@ -3838,8 +3844,13 @@ basic_ostream<Elem, Traits>& operator<<(basic_ostream<Elem, Traits>& str, const
return str << status.type() << L' ' << status.permissions();
}

struct directory_entry_wrapper {
directory_entry value;
};

template <typename Elem, typename Traits>
basic_ostream<Elem, Traits>& operator<<(basic_ostream<Elem, Traits>& str, const directory_entry& de) {
basic_ostream<Elem, Traits>& operator<<(basic_ostream<Elem, Traits>& str, const directory_entry_wrapper& de_wrapper) {
const directory_entry& de = de_wrapper.value;
return str << L"\n symlink_status: " << de.symlink_status() << L"\n status: " << de.status()
<< L"\n size: " << de.file_size() << L"\n last_write_time: "
<< de.last_write_time().time_since_epoch().count() << L"\n hard_link_count: " << de.hard_link_count();
Expand Down Expand Up @@ -3872,7 +3883,7 @@ void run_interactive_tests(int argc, wchar_t* argv[]) {
} else if (starts_with(arg, L"-stat:"sv)) {
wcerr << quoted(arg) << L" => " << status(the_rest) << "\n";
} else if (starts_with(arg, L"-de:"sv)) {
wcerr << quoted(arg) << L" => " << directory_entry(the_rest) << "\n";
wcerr << quoted(arg) << L" => " << directory_entry_wrapper{directory_entry(the_rest)} << "\n";
} else if (starts_with(arg, L"-mkdir:"sv)) {
wcerr << L"create_directory => " << create_directory(the_rest) << "\n";
} else if (starts_with(arg, L"-mkdirs:"sv)) {
Expand Down