名稱空間
變體
操作

std::filesystem::directory_entry::refresh

來自 cppreference.com
 
 
 
 
void refresh();
(1) (C++17 起)
void refresh( std::error_code& ec ) noexcept;
(2) (C++17 起)

檢查此目錄條目所指的檔案系統物件,並存儲其屬性,以便透過statusexistsis_regular_file及其他狀態訪問器檢索。

如果發生錯誤,任何快取屬性的值都是未指定的。

目錄

[編輯] 引數

ec - 非丟擲過載中用於錯誤報告的出參

[編輯] 返回值

(無)

[編輯] 異常

任何未標記為 noexcept 的過載都可能在記憶體分配失敗時丟擲 std::bad_alloc

1) 丟擲 std::filesystem::filesystem_error,構造時以 p 作為第一個路徑引數,OS 錯誤碼作為錯誤碼引數。
2) 如果 OS API 呼叫失敗,則將 std::error_code& 引數設定為 OS API 錯誤碼;如果未發生錯誤,則執行 ec.clear()

[編輯] 注意

許多用於目錄遍歷的低階作業系統 API 會在檢索下一個目錄條目的同時檢索檔案屬性。std::filesystem::directory_iterator 的建構函式和非 const 成員函式將這些屬性(如果有的話)儲存在指向的 std::filesystem::directory_entry 中,而無需呼叫 directory_entry::refresh,這使得在遍歷目錄條目時可以檢查其屬性,而無需進行額外的系統呼叫。

[編輯] 示例

[編輯] 參見

此目錄項所指定檔案的狀態;
此目錄項所指定檔案/符號連結的狀態
(public member function) [編輯]
檢查目錄項是否引用現有檔案系統物件
(public member function) [編輯]
檢查目錄項是否引用塊裝置
(public member function) [編輯]
檢查目錄項是否引用字元裝置
(public member function) [編輯]
檢查目錄項是否引用目錄
(public member function) [編輯]
檢查目錄項是否引用命名管道
(public member function) [編輯]
檢查目錄項是否引用“其他”檔案
(public member function) [編輯]
檢查目錄項是否引用常規檔案
(public member function) [編輯]
檢查目錄項是否引用命名 IPC 套接字
(public member function) [編輯]
檢查目錄項是否引用符號連結
(public member function) [編輯]
返回目錄條目所引用的檔案的大小
(public member function) [編輯]
返回目錄項所引用檔案的硬連結數量
(public member function) [編輯]
獲取目錄項所引用檔案的上次資料修改時間
(public member function) [編輯]