首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

ZipArchive::getExternalAttributesIndex

(PHP 5 >= 5.6.0, PHP 7, PECL zip >= 1.12.4)

ZipArchive::getExternalAttributesIndex - 检索由其索引定义的条目的外部属性

描述

代码语言:javascript
复制
bool ZipArchive::GetExternalAttributesIndex ( int $index , int &$opsys , int &$attr [, int $flags ] )

检索由其索引定义的条目的外部属性。

参数

index

入口索引。

opsys

成功时,接收由ZipArchive::OPSYS_常量之一定义的操作系统代码。

attr

成功时,接收外部属性。价值取决于操作系统。

flags

如果flags设置为ZipArchive::FL_UNCHANGED,则返回原始不变的属性。

返回值

成功时返回TRUE或失败时返回FALSE

示例

这个例子提取ZIP压缩文件test.zip的所有条目,并从外部属性中设置Unix权限。

Example #1 Extract all entries with Unix rights

代码语言:javascript
复制
<?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";
}
?>

← ZipArchive::getCommentName

ZipArchive::getExternalAttributesName →

扫码关注腾讯云开发者

领取腾讯云代金券