[fs.class.directory.entry]

# 31 Input/output library [[input.output]](./#input.output)

## 31.12 File systems [[filesystems]](filesystems#fs.class.directory.entry)

### 31.12.10 Class directory_entry [fs.class.directory.entry]

#### [31.12.10.1](#general) General [[fs.class.directory.entry.general]](fs.class.directory.entry.general)

[ð](#lib:directory_entry)

namespace std::filesystem {class directory_entry {public:// [[fs.dir.entry.cons]](#fs.dir.entry.cons "31.12.10.2 Constructors"), constructors and destructor directory_entry() noexcept = default;
 directory_entry(const directory_entry&) = default;
 directory_entry(directory_entry&&) noexcept = default; explicit directory_entry(const filesystem::path& p);
 directory_entry(const filesystem::path& p, error_code& ec); ~directory_entry(); // assignments directory_entry& operator=(const directory_entry&) = default;
 directory_entry& operator=(directory_entry&&) noexcept = default; // [[fs.dir.entry.mods]](#fs.dir.entry.mods "31.12.10.3 Modifiers"), modifiersvoid assign(const filesystem::path& p); void assign(const filesystem::path& p, error_code& ec); void replace_filename(const filesystem::path& p); void replace_filename(const filesystem::path& p, error_code& ec); void refresh(); void refresh(error_code& ec) noexcept; // [[fs.dir.entry.obs]](#fs.dir.entry.obs "31.12.10.4 Observers"), observersconst filesystem::path& path() const noexcept; operator const filesystem::path&() const noexcept; bool exists() const; bool exists(error_code& ec) const noexcept; bool is_block_file() const; bool is_block_file(error_code& ec) const noexcept; bool is_character_file() const; bool is_character_file(error_code& ec) const noexcept; bool is_directory() const; bool is_directory(error_code& ec) const noexcept; bool is_fifo() const; bool is_fifo(error_code& ec) const noexcept; bool is_other() const; bool is_other(error_code& ec) const noexcept; bool is_regular_file() const; bool is_regular_file(error_code& ec) const noexcept; bool is_socket() const; bool is_socket(error_code& ec) const noexcept; bool is_symlink() const; bool is_symlink(error_code& ec) const noexcept;
 uintmax_t file_size() const;
 uintmax_t file_size(error_code& ec) const noexcept;
 uintmax_t hard_link_count() const;
 uintmax_t hard_link_count(error_code& ec) const noexcept;
 file_time_type last_write_time() const;
 file_time_type last_write_time(error_code& ec) const noexcept;
 file_status status() const;
 file_status status(error_code& ec) const noexcept;
 file_status symlink_status() const;
 file_status symlink_status(error_code& ec) const noexcept; bool operator==(const directory_entry& rhs) const noexcept;
 strong_ordering operator<=>(const directory_entry& rhs) const noexcept; // [[fs.dir.entry.io]](#fs.dir.entry.io "31.12.10.5 Inserter"), insertertemplate<class charT, class traits>friend basic_ostream<charT, traits>&operator<<(basic_ostream<charT, traits>& os, const directory_entry& d); private: filesystem::path *path-object*; // *exposition only*};}

[1](#general-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L16110)

A directory_entry object stores a path object
and may store additional objects for file attributes
such as hard link count, status, symlink status, file size, and last write time[.](#general-1.sentence-1)

[2](#general-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L16116)

Implementations should store such additional file attributes
during directory iteration if their values are available
and storing the values would allow the implementation to eliminate file system accesses
by directory_entry observer functions ([[fs.op.funcs]](fs.op.funcs "31.12.13 Filesystem operation functions"))[.](#general-2.sentence-1)

Such stored file attribute values are said to be [*cached*](#def:file_attributes,cached "31.12.10.1 General [fs.class.directory.entry.general]")[.](#general-2.sentence-2)

[3](#general-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L16123)

[*Note [1](#general-note-1)*:

directory_iterator can cache
already available attribute values
directly into a directory_entry object
without the cost of a call to refresh()[.](#general-3.sentence-1)

â *end note*]

[4](#general-4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L16131)

[*Example [1](#general-example-1)*: using namespace std::filesystem;

// use possibly cached last write time to minimize disk accessesfor (auto&& x : directory_iterator(".")){ std::cout << x.path() << " " << x.last_write_time() << std::endl;}// call refresh() to refresh a stale cachefor (auto&& x : directory_iterator(".")){ lengthy_function(x.path()); // cache becomes stale x.refresh();
 std::cout << x.path() << " " << x.last_write_time() << std::endl;}

On implementations that do not cache the last write time,
both loops will result in a potentially expensive call
to the std​::​filesystem​::​last_write_time function[.](#general-4.sentence-1)

On implementations that do cache the last write time,
the first loop will use the cached value and so
will not result in a potentially expensive call
to the std​::​filesystem​::​last_write_time function[.](#general-4.sentence-2)

The code is portable to any implementation,
regardless of whether or not it employs caching[.](#general-4.sentence-3)

â *end example*]

#### [31.12.10.2](#fs.dir.entry.cons) Constructors [[fs.dir.entry.cons]](fs.dir.entry.cons)

[ð](#lib:directory_entry,constructor)

`explicit directory_entry(const filesystem::path& p);
directory_entry(const filesystem::path& p, error_code& ec);
`

[1](#fs.dir.entry.cons-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L16172)

*Effects*: Calls refresh() or refresh(ec), respectively[.](#fs.dir.entry.cons-1.sentence-1)

[2](#fs.dir.entry.cons-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L16176)

*Postconditions*: path() == p if no error occurs,
otherwise path() == filesystem​::​path()[.](#fs.dir.entry.cons-2.sentence-1)

[3](#fs.dir.entry.cons-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L16181)

*Throws*: As specified in [[fs.err.report]](fs.err.report "31.12.5 Error reporting")[.](#fs.dir.entry.cons-3.sentence-1)

#### [31.12.10.3](#fs.dir.entry.mods) Modifiers [[fs.dir.entry.mods]](fs.dir.entry.mods)

[ð](#lib:assign,directory_entry)

`void assign(const filesystem::path& p);
void assign(const filesystem::path& p, error_code& ec);
`

[1](#fs.dir.entry.mods-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L16195)

*Effects*: Equivalent to *path-object* = p,
then refresh() or refresh(ec), respectively[.](#fs.dir.entry.mods-1.sentence-1)

If an error occurs, the values of any cached attributes are unspecified[.](#fs.dir.entry.mods-1.sentence-2)

[2](#fs.dir.entry.mods-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L16201)

*Throws*: As specified in [[fs.err.report]](fs.err.report "31.12.5 Error reporting")[.](#fs.dir.entry.mods-2.sentence-1)

[ð](#lib:replace_filename,directory_entry)

`void replace_filename(const filesystem::path& p);
void replace_filename(const filesystem::path& p, error_code& ec);
`

[3](#fs.dir.entry.mods-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L16213)

*Effects*: Equivalent to *path-object*.replace_filename(p),
then refresh() or refresh(ec), respectively[.](#fs.dir.entry.mods-3.sentence-1)

If an error occurs, the values of any cached attributes are unspecified[.](#fs.dir.entry.mods-3.sentence-2)

[4](#fs.dir.entry.mods-4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L16219)

*Throws*: As specified in [[fs.err.report]](fs.err.report "31.12.5 Error reporting")[.](#fs.dir.entry.mods-4.sentence-1)

[ð](#lib:refresh,directory_entry)

`void refresh();
void refresh(error_code& ec) noexcept;
`

[5](#fs.dir.entry.mods-5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L16231)

*Effects*: Stores the current values of any cached attributes of the file p resolves to[.](#fs.dir.entry.mods-5.sentence-1)

If an error occurs, an error is reported ([[fs.err.report]](fs.err.report "31.12.5 Error reporting"))
and the values of any cached attributes are unspecified[.](#fs.dir.entry.mods-5.sentence-2)

[6](#fs.dir.entry.mods-6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L16237)

*Throws*: As specified in [[fs.err.report]](fs.err.report "31.12.5 Error reporting")[.](#fs.dir.entry.mods-6.sentence-1)

[7](#fs.dir.entry.mods-7)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L16241)

[*Note [1](#fs.dir.entry.mods-note-1)*:

Implementations of directory_iterator ([[fs.class.directory.iterator]](fs.class.directory.iterator "31.12.11 Class directory_­iterator"))
are prohibited from directly or indirectly calling the refresh function
as described in [[fs.class.directory.iterator.general]](fs.class.directory.iterator.general "31.12.11.1 General")[.](#fs.dir.entry.mods-7.sentence-1)

â *end note*]

#### [31.12.10.4](#fs.dir.entry.obs) Observers [[fs.dir.entry.obs]](fs.dir.entry.obs)

[1](#fs.dir.entry.obs-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L16251)

Unqualified function names in the *Returns*: elements of thedirectory_entry observers described below refer to members of thestd​::​filesystem namespace[.](#fs.dir.entry.obs-1.sentence-1)

[ð](#lib:path,directory_entry)

`const filesystem::path& path() const noexcept;
operator const filesystem::path&() const noexcept;
`

[2](#fs.dir.entry.obs-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L16264)

*Returns*: *path-object*[.](#fs.dir.entry.obs-2.sentence-1)

[ð](#lib:exists,directory_entry)

`bool exists() const;
bool exists(error_code& ec) const noexcept;
`

[3](#fs.dir.entry.obs-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L16276)

*Returns*: exists(this->status()) or exists(this->status(ec)), respectively[.](#fs.dir.entry.obs-3.sentence-1)

[4](#fs.dir.entry.obs-4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L16280)

*Throws*: As specified in [[fs.err.report]](fs.err.report "31.12.5 Error reporting")[.](#fs.dir.entry.obs-4.sentence-1)

[ð](#lib:is_block_file,directory_entry)

`bool is_block_file() const;
bool is_block_file(error_code& ec) const noexcept;
`

[5](#fs.dir.entry.obs-5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L16292)

*Returns*: is_block_file(this->status()) or is_block_file(this->status(ec)), respectively[.](#fs.dir.entry.obs-5.sentence-1)

[6](#fs.dir.entry.obs-6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L16296)

*Throws*: As specified in [[fs.err.report]](fs.err.report "31.12.5 Error reporting")[.](#fs.dir.entry.obs-6.sentence-1)

[ð](#lib:is_character_file,directory_entry)

`bool is_character_file() const;
bool is_character_file(error_code& ec) const noexcept;
`

[7](#fs.dir.entry.obs-7)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L16308)

*Returns*: is_character_file(this->status()) or is_character_file(this->status(ec)), respectively[.](#fs.dir.entry.obs-7.sentence-1)

[8](#fs.dir.entry.obs-8)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L16312)

*Throws*: As specified in [[fs.err.report]](fs.err.report "31.12.5 Error reporting")[.](#fs.dir.entry.obs-8.sentence-1)

[ð](#lib:is_directory,directory_entry)

`bool is_directory() const;
bool is_directory(error_code& ec) const noexcept;
`

[9](#fs.dir.entry.obs-9)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L16324)

*Returns*: is_directory(this->status()) or is_directory(this->status(ec)), respectively[.](#fs.dir.entry.obs-9.sentence-1)

[10](#fs.dir.entry.obs-10)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L16328)

*Throws*: As specified in [[fs.err.report]](fs.err.report "31.12.5 Error reporting")[.](#fs.dir.entry.obs-10.sentence-1)

[ð](#lib:is_fifo,directory_entry)

`bool is_fifo() const;
bool is_fifo(error_code& ec) const noexcept;
`

[11](#fs.dir.entry.obs-11)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L16340)

*Returns*: is_fifo(this->status()) or is_fifo(this->status(ec)), respectively[.](#fs.dir.entry.obs-11.sentence-1)

[12](#fs.dir.entry.obs-12)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L16344)

*Throws*: As specified in [[fs.err.report]](fs.err.report "31.12.5 Error reporting")[.](#fs.dir.entry.obs-12.sentence-1)

[ð](#lib:is_other,directory_entry)

`bool is_other() const;
bool is_other(error_code& ec) const noexcept;
`

[13](#fs.dir.entry.obs-13)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L16356)

*Returns*: is_other(this->status()) or is_other(this->status(ec)), respectively[.](#fs.dir.entry.obs-13.sentence-1)

[14](#fs.dir.entry.obs-14)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L16360)

*Throws*: As specified in [[fs.err.report]](fs.err.report "31.12.5 Error reporting")[.](#fs.dir.entry.obs-14.sentence-1)

[ð](#lib:is_regular_file,directory_entry)

`bool is_regular_file() const;
bool is_regular_file(error_code& ec) const noexcept;
`

[15](#fs.dir.entry.obs-15)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L16372)

*Returns*: is_regular_file(this->status()) or is_regular_file(this->status(ec)), respectively[.](#fs.dir.entry.obs-15.sentence-1)

[16](#fs.dir.entry.obs-16)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L16376)

*Throws*: As specified in [[fs.err.report]](fs.err.report "31.12.5 Error reporting")[.](#fs.dir.entry.obs-16.sentence-1)

[ð](#lib:is_socket,directory_entry)

`bool is_socket() const;
bool is_socket(error_code& ec) const noexcept;
`

[17](#fs.dir.entry.obs-17)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L16388)

*Returns*: is_socket(this->status()) or is_socket(this->status(ec)), respectively[.](#fs.dir.entry.obs-17.sentence-1)

[18](#fs.dir.entry.obs-18)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L16392)

*Throws*: As specified in [[fs.err.report]](fs.err.report "31.12.5 Error reporting")[.](#fs.dir.entry.obs-18.sentence-1)

[ð](#lib:is_symlink,directory_entry)

`bool is_symlink() const;
bool is_symlink(error_code& ec) const noexcept;
`

[19](#fs.dir.entry.obs-19)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L16404)

*Returns*: is_symlink(this->symlink_status()) or is_symlink(this->symlink_status(ec)), respectively[.](#fs.dir.entry.obs-19.sentence-1)

[20](#fs.dir.entry.obs-20)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L16408)

*Throws*: As specified in [[fs.err.report]](fs.err.report "31.12.5 Error reporting")[.](#fs.dir.entry.obs-20.sentence-1)

[ð](#lib:file_size,directory_entry)

`uintmax_t file_size() const;
uintmax_t file_size(error_code& ec) const noexcept;
`

[21](#fs.dir.entry.obs-21)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L16420)

*Returns*: If cached, the file size attribute value[.](#fs.dir.entry.obs-21.sentence-1)

Otherwise, file_size(path()) or file_size(path(), ec), respectively[.](#fs.dir.entry.obs-21.sentence-2)

[22](#fs.dir.entry.obs-22)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L16425)

*Throws*: As specified in [[fs.err.report]](fs.err.report "31.12.5 Error reporting")[.](#fs.dir.entry.obs-22.sentence-1)

[ð](#lib:hard_link_count,directory_entry)

`uintmax_t hard_link_count() const;
uintmax_t hard_link_count(error_code& ec) const noexcept;
`

[23](#fs.dir.entry.obs-23)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L16437)

*Returns*: If cached, the hard link count attribute value[.](#fs.dir.entry.obs-23.sentence-1)

Otherwise, hard_link_count(path()) or hard_link_count(path(), ec), respectively[.](#fs.dir.entry.obs-23.sentence-2)

[24](#fs.dir.entry.obs-24)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L16442)

*Throws*: As specified in [[fs.err.report]](fs.err.report "31.12.5 Error reporting")[.](#fs.dir.entry.obs-24.sentence-1)

[ð](#lib:last_write_time,directory_entry)

`file_time_type last_write_time() const;
file_time_type last_write_time(error_code& ec) const noexcept;
`

[25](#fs.dir.entry.obs-25)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L16454)

*Returns*: If cached, the last write time attribute value[.](#fs.dir.entry.obs-25.sentence-1)

Otherwise, last_write_time(path()) or last_write_time(path(), ec), respectively[.](#fs.dir.entry.obs-25.sentence-2)

[26](#fs.dir.entry.obs-26)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L16459)

*Throws*: As specified in [[fs.err.report]](fs.err.report "31.12.5 Error reporting")[.](#fs.dir.entry.obs-26.sentence-1)

[ð](#lib:status,directory_entry)

`file_status status() const;
file_status status(error_code& ec) const noexcept;
`

[27](#fs.dir.entry.obs-27)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L16471)

*Returns*: If cached, the status attribute value[.](#fs.dir.entry.obs-27.sentence-1)

Otherwise, status(path()) or status(path(), ec), respectively[.](#fs.dir.entry.obs-27.sentence-2)

[28](#fs.dir.entry.obs-28)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L16476)

*Throws*: As specified in [[fs.err.report]](fs.err.report "31.12.5 Error reporting")[.](#fs.dir.entry.obs-28.sentence-1)

[ð](#lib:symlink_status,directory_entry)

`file_status symlink_status() const;
file_status symlink_status(error_code& ec) const noexcept;
`

[29](#fs.dir.entry.obs-29)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L16488)

*Returns*: If cached, the symlink status attribute value[.](#fs.dir.entry.obs-29.sentence-1)

Otherwise, symlink_status(path()) or symlink_status(path(), ec), respectively[.](#fs.dir.entry.obs-29.sentence-2)

[30](#fs.dir.entry.obs-30)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L16493)

*Throws*: As specified in [[fs.err.report]](fs.err.report "31.12.5 Error reporting")[.](#fs.dir.entry.obs-30.sentence-1)

[ð](#lib:operator==,directory_entry)

`bool operator==(const directory_entry& rhs) const noexcept;
`

[31](#fs.dir.entry.obs-31)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L16504)

*Returns*: *path-object* == rhs.*path-object*[.](#fs.dir.entry.obs-31.sentence-1)

[ð](#lib:operator%3c=%3e,directory_entry)

`strong_ordering operator<=>(const directory_entry& rhs) const noexcept;
`

[32](#fs.dir.entry.obs-32)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L16515)

*Returns*: *path-object* <=> rhs.*path-object*[.](#fs.dir.entry.obs-32.sentence-1)

#### [31.12.10.5](#fs.dir.entry.io) Inserter [[fs.dir.entry.io]](fs.dir.entry.io)

[ð](#lib:operator%3c%3c,directory_entry)

`template<class charT, class traits>
  friend basic_ostream<charT, traits>&
    operator<<(basic_ostream<charT, traits>& os, const directory_entry& d);
`

[1](#fs.dir.entry.io-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L16530)

*Effects*: Equivalent to: return os << d.path();
