這個物件是在分析階段建立,代表執行階段會讀取或寫入的檔案或目錄。這不是開啟的檔案控制代碼,無法直接用於讀取或寫入檔案內容。而是將其傳遞至動作建立函式,在規則實作函式中建構動作圖表。詳情請參閱「規則」頁面。
如果將 File
傳遞至 Args
物件,但未使用 map_each
函式,系統會擷取 path
欄位的值,並將其轉換為字串。
成員
basename
string File.basename
目錄名稱
string File.dirname
擴充功能
string File.extension
is_directory
bool File.is_directory
is_source
bool File.is_source
owner
Label File.owner
None
。
路徑
string File.path
short_path
。根目錄可能為空白,通常非產生檔案就是如此。如果是產生的檔案,通常會包含特定於設定的路徑片段,其中會編碼建構該檔案時使用的目標 CPU 架構等項目。如果檔案位於二進位的執行檔中,請使用 short_path
做為檔案對應的路徑。
root
root File.root
short_path
string File.short_path
tree_relative_path
string File.tree_relative_path
tree_relative_path
僅適用於動作指令中目錄的展開檔案,也就是 Args.add_all()。如果是其他類型的檔案,存取這個欄位會發生錯誤。