directory_entry Class

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

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.

class directory_entry;  

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++).

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() = 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.

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

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

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

The defaulted member assignment operators behave as expected.

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

The member function returns mypath == right.mypath.

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

The member function returns mypath < right.mypath.

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

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

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

The member function returns right < *this.

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

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


// retained  

The member operator returns mypath.

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

The member function returns mypath.

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

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).

Header: <experimental/filesystem>

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

Header Files Reference
<filesystem>

Show: