rar:// - RAR

rar:// - RAR


설명

래퍼는 아카이브에 저장된 RAR 아카이브(상대 또는 절대), 선택적 별표(*), 선택적 숫자 기호(#) 및 선택적 url 인코딩 항목 이름에 대한 URL 인코딩 경로를 사용합니다. 항목 이름을 지정하려면 숫자 기호가 필요합니다. 항목 이름의 선행 슬래시는 선택 사항입니다.

이 래퍼는 파일과 디렉터리를 모두 열 수 있습니다. 디렉토리를 열 때 별표 기호는 디렉토리 항목 이름이 인코딩되지 않은 상태로 반환되도록 합니다. 지정하지 않으면 URL 인코딩으로 반환됩니다. 그 이유는 URL 인코딩 데이터처럼 보이는 파일 이름이 있는 경우 래퍼가 RecursiveDirectoryIterator와 같은 내장 기능과 함께 올바르게 사용될 수 있도록 하기 위해서입니다.

파운드 기호와 항목 이름 부분이 포함되지 않은 경우 아카이브의 루트가 표시됩니다. 이것은 루트 디렉토리가 아카이브의 개별 항목에 저장되지 않기 때문에 결과 스트림에 수정 시간과 같은 정보가 포함되지 않는다는 점에서 일반 디렉토리와 다릅니다. RecursiveDirectoryIterator와 함께 래퍼를 사용하려면 루트에 액세스할 때 URL에 숫자 기호가 포함되어야 하위 URL이 올바르게 구성될 수 있습니다.

참고: 이 래퍼는 기본적으로 활성화되어 있지 않습니다.

rar:// 래퍼를 사용하려면 » PECL에서 제공되는 » rar 확장 프로그램을 설치해야 합니다.

rar:// Available since PECL rar 3.0.0


용법

  • rar://[*][#[]]

옵션

Wrapper Summary

Attribute Supported
Restricted by allow_url_fopen No
Restricted by allow_url_include No
Allows Reading Yes
Allows Writing No
Allows Appending No
Allows Simultaneous Reading and Writing No
Supports stat() Yes
Supports unlink() No
Supports rename() No
Supports mkdir() No
Supports rmdir() No

Context options

Name Usage Default
open_password The password used to encrypt the headers of the archive, if any. WinRAR will encrypt all the files with the same password as the headers password when the later is present, so for archives with encrypted headers, file_password will be ignored.  
file_password The password used to encrypt a file, if any. If the headers are also encrypted, this option will be ignored in favor of open_password. The reason there are two options is to cover the possibility of supporting archives with different headers and file passwords, should those archives arise. Note that if the archive does not have its headers encrypted, open_password will be ignored and this option must be used instead.  
volume_callback A callback to determine the path of missing volumes. See RarArchive::open() for more information.  

Examples

예제 #1 RAR 아카이브 탐색

                  
<?php

class MyRecDirIt extends RecursiveDirectoryIterator {
    function current() {
        return rawurldecode($this->getSubPathName()) .
            (is_dir(parent::current())?" [DIR]":"");
    }
}

$f = "rar://" . rawurlencode(dirname(__FILE__)) .
    DIRECTORY_SEPARATOR . 'dirs_and_extra_headers.rar#';

$it = new RecursiveTreeIterator(new MyRecDirIt($f));

foreach ($it as $s) {
    echo $s, "\n";
}
?>
                  
                

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

|-allow_everyone_ni [DIR]
|-file1.txt
|-file2_אּ.txt
|-with_streams.txt
\-אּ [DIR]
  |-אּ\%2Fempty%2E [DIR]
  | \-אּ\%2Fempty%2E\file7.txt
  |-אּ\empty [DIR]
  |-אּ\file3.txt
  |-אּ\file4_אּ.txt
  \-אּ\אּ_2 [DIR]
    |-אּ\אּ_2\file5.txt
    \-אּ\אּ_2\file6_אּ.txt
                

예제 #2 암호화된 파일 열기(헤더 암호화)

                  
<?php
$stream = fopen("rar://" .
    rawurlencode(dirname(__FILE__)) . DIRECTORY_SEPARATOR .
    'encrypted_headers.rar' . '#encfile1.txt', "r", false,
    stream_context_create(
        array(
            'rar' =>
                array(
                    'open_password' => 'samplepassword'
                )
            )
        )
    );
var_dump(stream_get_contents($stream));
/* creation and last access date is opt-in in WinRAR, hence most
 * files don't have them */
var_dump(fstat($stream));
?>
                  
                

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

string(26) "Encrypted file 1 contents."
Array
(
    [0] => 0
    [1] => 0
    [2] => 33206
    [3] => 1
    [4] => 0
    [5] => 0
    [6] => 0
    [7] => 26
    [8] => 0
    [9] => 1259550052
    [10] => 0
    [11] => -1
    [12] => -1
    [dev] => 0
    [ino] => 0
    [mode] => 33206
    [nlink] => 1
    [uid] => 0
    [gid] => 0
    [rdev] => 0
    [size] => 26
    [atime] => 0
    [mtime] => 1259550052
    [ctime] => 0
    [blksize] => -1
    [blocks] => -1
)