(PHP 5 >= 5.6.0,PHP 7,PHP 8,PECL zip >= 1.12.4)
ZipArchive::getExternalAttributesIndex — 擷取由其索引定義的項目的外部屬性
$index
,&$opsys
,&$attr
,$flags
= 0取得由索引定義的項目的外部屬性。
index
項目的索引。
opsys
成功時,接收由其中一個 ZipArchive::OPSYS_ 常數定義的操作系統代碼。
attr
成功時,接收外部屬性。值取決於操作系統。
flags
如果 flags 設定為 ZipArchive::FL_UNCHANGED
,則會返回原始未更改的屬性。
此範例提取 ZIP 檔案 test.zip 的所有項目,並從外部屬性設定 Unix 權限。
範例 #1 提取所有具有 Unix 權限的項目
<?php
$zip = new ZipArchive();
if ($zip->open('test.zip') === TRUE) {
for ($idx=0 ; $s = $zip->statIndex($idx) ; $idx++) {
if ($zip->extractTo('.', $s['name'])) {
if ($zip->getExternalAttributesIndex($idx, $opsys, $attr)
&& $opsys==ZipArchive::OPSYS_UNIX) {
chmod($s['name'], ($attr >> 16) & 0777);
}
}
}
$zip->close();
echo "Ok\n";
} else {
echo "KO\n";
}
?>