Share via


directory_entry Class

 

The latest version of this topic can be found at directory_entry Class.

Describes an object that is returned by *X, where X is a directory_iterator or a recursive_directory_iterator.

Syntax

class directory_entry;  

Remarks

The class stores an object of type path. The stored path can be an instance of the path Class or of a type that is derived from path. It also stores two file_type values; one that represents what is known about the status of the stored file name, and another that represents what is known about the symbolic link status of the file name.

For more information and code examples, see File System Navigation (C++).

assign

void assign(const std::experimental::filesystem::v1::path& pval,  
    file_status stat_arg = file_status(),  
    file_status symstat_arg = file_status());

The member function assigns pval to mypath, stat to mystat, and symstat to mysymstat.

directory_entry

directory_entry() = default;  
directory_entry(const directory_entry&) = default;  
directory_entry(directory_entry&&) noexcept = default;  
explicit directory_entry(const std::experimental::filesystem::v1::path& pval,  
    file_status stat_arg = file_status(),  
    file_status symstat_arg = file_status());

The defaulted constructors behave as expected. The fourth constructor initializes mypath to pval, mystat to stat_arg, and mysymstat to symstat_arg.

operator!=

bool operator!=(const directory_entry& right) const noexcept;  

The member function returns !(*this == right).

operator=

directory_entry& operator=(const directory_entry&) = default;  
directory_entry& operator=(directory_entry&&) noexcept = default;  

The defaulted member assignment operators behave as expected.

operator==

bool operator==(const directory_entry& right) const noexcept;  

The member function returns mypath == right.mypath.

operator<

 
bool operator<(const directory_entry& right) const noexcept;  

The member function returns mypath < right.mypath.

operator<=

bool operator<=(const directory_entry& right) const noexcept;  

The member function returns !(right < *this).

operator>

bool operator>(const directory_entry& right) const noexcept;  

The member function returns right < *this.

operator>=

bool operator>=(const directory_entry& right) const noexcept;  

The member function returns !(*this < right).

operator const path_type&

// retained  

The member operator returns mypath.

path

const std::experimental::filesystem::v1::path& path() const noexcept;  

The member function returns mypath.

replace_filename

void replace_filename(const std::experimental::filesystem::v1::path& pval,  
    file_status stat_arg = file_status(),  
    file_status symstat_arg = file_status());

The member function replaces mypath with mypath.parent_path() / pval, mystat with stat_arg, and mysymstat with symstat_arg

status

file_status status() const;

 
file_status status(
    error_code& ec) const noexcept;  
Otherwise, mystat = status(mypval).  

Both member functions return mystat possibly first altered as follows:

  1. If status_known(mystat) then do nothing.

  2. Otherwise, if !status_known(mysymstat) && !is_symlink(mysymstat) then mystat = mysymstat.

file_status symlink_status() const;

 
file_status symlink_status(error_code& ec) const noexcept;  

Both member functions return mysymstat possibly first altered as follows:If status_known(mysymstat) then do nothing. Otherwise, mysymstat = symlink_status(mypval).

Requirements

Header: <experimental/filesystem>

Namespace: std::experimental::filesystem::v1

See Also

Header Files Reference
<filesystem>