Important
この記事では、directory_entryの標準std::experimental::filesystem実装について説明します。 この実装は、 ISO/IEC JTC 1/SC 22/WG 21 N4100 に記載されているファイル システム技術仕様に基づいています。
std::filesystemではなく、C++17 std::filesystem実装と互換性がありません。 実験用の実装は、MSVC ツールセット バージョン 14.51 以降で削除されました。 現在の C++17 std::filesystem バージョンについては、 directory_entry クラスを参照してください。
*Xによって返されるオブジェクトについて説明します。ここで、X はdirectory_iteratorまたはrecursive_directory_iteratorです。
構文
class directory_entry;
注釈
クラスには、 path型のオブジェクトが格納されます。 格納される path には、 path クラスのインスタンス、または pathから派生した型のインスタンスを指定できます。 また、2 つの file_type 値も格納されます。 1 つの値は、格納されているファイル名の状態を表します。 もう 1 つは、ファイル名のシンボリック リンクの状態を表します。
Constructors
| コンストラクター | Description |
|---|---|
directory_entry |
既定のコンストラクターは想定どおりに動作します。 4 番目のコンストラクターは、mypathを pval に初期化し、stat_argにmystatし、symstat_argにmysymstatします。 |
メンバー関数
| メンバー関数 | Description |
|---|---|
assign |
メンバー関数は 、pval を mypathに割り当て、 stat を mystatに割り当て、 symstat を mysymstatに割り当てます。 |
path |
メンバー関数は mypathを返します。 |
replace_filename |
メンバー関数は、mypathを mypath.parent_path() / pval に置き換え、mystatを stat_arg に置き換え、mysymstatを symstat_arg に置き換えます |
status |
どちらのメンバー関数も、最初に変更 mystat を返します。 |
symlink_status |
どちらのメンバー関数も、最初に変更 mysymstat を返します。 |
Operators
| Operator | Description |
|---|---|
operator!= |
!(*this == right) を返します。 |
operator= |
既定のメンバー割り当て演算子は、想定どおりに動作します。 |
operator== |
mypath == right.mypath を返します。 |
operator< |
mypath < right.mypath を返します。 |
operator<= |
!(right < *this) を返します。 |
operator> |
right < *this を返します。 |
operator>= |
!(*this < right) を返します。 |
operator const path_type& |
mypath を返します。 |
Requirements
ヘッダー: <experimental/filesystem>
名前 空間:std::experimental::filesystem
割り当て
メンバー関数は、pval をmypathに割り当て、mystatにstat_argし、mysymstatにsymstat_argします。
void assign(const std::experimental::filesystem::path& pval,
file_status stat_arg = file_status(),
file_status symstat_arg = file_status());
パラメーター
pval
保存されているファイル名のパス。
stat_arg
保存されているファイル名の状態。
symstat_arg
保存されているファイル名のシンボリック リンクの状態。
directory_entry
既定のコンストラクターは想定どおりに動作します。 4 番目のコンストラクターは、mypathを pval に初期化し、stat_argにmystatし、symstat_argにmysymstatします。
directory_entry() = default;
directory_entry(const directory_entry&) = default;
directory_entry(directory_entry&&) noexcept = default;
explicit directory_entry(const std::experimental::filesystem::path& pval,
file_status stat_arg = file_status(),
file_status symstat_arg = file_status());
パラメーター
pval
保存されているファイル名のパス。
stat_arg
保存されているファイル名の状態。
symstat_arg
保存されているファイル名のシンボリック リンクの状態。
operator!=
メンバー関数は !(*this == right)を返します。
bool operator!=(const directory_entry& right) const noexcept;
パラメーター
right
directory_entry
と比較されるdirectory_entry。
operator=
既定のメンバー割り当て演算子は、想定どおりに動作します。
directory_entry& operator=(const directory_entry&) = default;
directory_entry& operator=(directory_entry&&) noexcept = default;
パラメーター
right
directory_entry
にコピーされるdirectory_entry。
operator==
メンバー関数は mypath == right.mypathを返します。
bool operator==(const directory_entry& right) const noexcept;
パラメーター
right
directory_entry
と比較されるdirectory_entry。
operator<
メンバー関数は mypath < right.mypathを返します。
bool operator<(const directory_entry& right) const noexcept;
パラメーター
right
directory_entry
と比較されるdirectory_entry。
operator<=
メンバー関数は !(right < *this)を返します。
bool operator<=(const directory_entry& right) const noexcept;
パラメーター
right
directory_entry
と比較されるdirectory_entry。
operator>
メンバー関数は right < *thisを返します。
bool operator>(const directory_entry& right) const noexcept;
パラメーター
right
directory_entry
と比較されるdirectory_entry。
operator>=
メンバー関数は !(*this < right)を返します。
bool operator>=(const directory_entry& right) const noexcept;
パラメーター
right
directory_entry
と比較されるdirectory_entry。
operator const path_type&
メンバー演算子は mypathを返します。
operator const std::experimental::filesystem::path&() const;
パス
メンバー関数は mypathを返します。
const std::experimental::filesystem::path& path() const noexcept;
replace_filename
メンバー関数は、mypathを mypath.parent_path() / pval に置き換え、mystatを stat_arg に置き換え、mysymstatを symstat_arg に置き換えます
void replace_filename(
const std::experimental::filesystem::path& pval,
file_status stat_arg = file_status(),
file_status symstat_arg = file_status());
パラメーター
pval
保存されているファイル名のパス。
stat_arg
保存されているファイル名の状態。
symstat_arg
保存されているファイル名のシンボリック リンクの状態。
状態
どちらのメンバー関数も mystat 最初に次のように変更される可能性があります。
status_known(mystat)場合は何もしません。それ以外の場合は、
!status_known(mysymstat) && !is_symlink(mysymstat)mystat = mysymstat。
file_status status() const;
file_status status(error_code& ec) const noexcept;
パラメーター
Ec
状態エラー コード。
symlink_status
どちらのメンバー関数も mysymstat 最初に次のように変更される可能性があります: status_known(mysymstat) 場合は何もしません。 それ以外の場合は、 mysymstat = symlink_status(mypval)。
file_status symlink_status() const;
file_status symlink_status(error_code& ec) const noexcept;
パラメーター
Ec
状態エラー コード。