(PECL xattr >= 0.9.0)
xattr_list — 取得延伸屬性列表
這個函式會取得一個檔案的擴充屬性名稱列表。
擴充屬性有兩個不同的命名空間:user 和 root。user 命名空間適用於所有使用者,而 root 命名空間僅適用於具有 root 權限的使用者。 xattr 預設操作 user 命名空間,但可以使用 flags
參數更改。
filename
檔案的路徑。
flags
XATTR_DONTFOLLOW |
不要追蹤符號連結,而是在符號連結本身上操作。 |
XATTR_ROOT |
在 root(受信任的)命名空間中設定屬性。需要 root 權限。 |
此函式會傳回一個包含擴充屬性名稱的陣列。
範例 #1 印出檔案所有擴充屬性的名稱
<?php
$file = 'some_file';
$root_attributes = xattr_list($file, XATTR_ROOT);
$user_attributes = xattr_list($file);
echo "Root 屬性:\n";
foreach ($root_attributes as $attr_name) {
printf("%s\n", $attr_name);
}
echo "\n User 屬性:\n";
foreach ($user_attributes as $attr_name) {
printf("%s\n", $attr_name);
}
?>