RarArchive::setAllowBroken

(PECL rar >= 3.0.0)

RarArchive :: setAllowBroken - 깨진 아카이브 열기 허용 여부


설명

Object-oriented style (method):

public RarArchive::setAllowBroken(bool $allow_broken): bool

Procedural style:

rar_allow_broken_set(RarArchive $rarfile, bool $allow_broken): bool

이 메서드는 손상된 아카이브를 읽을 수 있는지 또는 아카이브 항목을 추출하려는 모든 작업이 실패할지 여부를 정의합니다. 깨진 아카이브는 파일을 열 때 오류가 감지되지 않지만 항목을 읽을 때 오류가 발생하는 아카이브입니다.


매개변수

rarfile
rar_open()으로 열린 RarArchive 객체.
allow_broken
깨진 파일 읽기를 허용할지(true) 허용하지 않을지(false)

반환 값

실패 시 true 또는 false를 반환합니다. 파일이 이미 닫힌 경우에만 실패합니다.


Examples

예제 #1 객체 지향 스타일

                  
<?php
function retnull() { return null; }
$file = dirname(__FILE__) . "/multi_broken.part1.rar";
/* Third argument omits "volume not found" message */
$a = RarArchive::open($file, null, 'retnull');
$a->setAllowBroken(true);
foreach ($a->getEntries() as $e) {
    echo "$e\n";
}
var_dump(count($a));
?>
                  
                

위의 예는 다음과 유사한 결과를 출력합니다.

RarEntry for file "file1.txt" (52b28202)
int(1)
                

예제 #2 절차 스타일

                  
<?php
function retnull() { return null; }
$file = dirname(__FILE__) . "/multi_broken.part1.rar";
/* Third argument omits "volume not found" message */
$a = rar_open($file, null, 'retnull');
rar_allow_broken_set($a, true);
foreach (rar_list($a) as $e) {
    echo "$e\n";
}
var_dump(count($a));
?>
                  
                

기타