Rar アーカイブ

目次

RarArchive クラス

はじめに

このクラスは RAR アーカイブをあらわします。これは複数のパーツで構成されることもあり、 中に RAR エントリ (ファイルやディレクトリ、そしてシンボリックリンクなどの特殊なオブジェクト) を含みます。

このクラスのオブジェクトの中身を走査したり、RAR アーカイブに格納されているエントリを取り出したりすることができます。 このエントリは、 RarArchive::getEntryRarArchive::getEntries を使って取得することもできます。

クラス概要

RarArchive
final class RarArchive implements Traversable {
/* メソッド */
public bool close()
public string getComment()
public arrayfalse getEntries()
public RarEntryfalse getEntry(string $entryname)
public bool isBroken()
public bool isSolid()
public static RarArchivefalse open(string $filename, string $password = NULL, callable $volume_callback = NULL)
public bool setAllowBroken(bool $allow_broken)
public string __toString()
}

The RarEntry class

はじめに

A RAR entry, representing a directory or a compressed file inside a RAR archive.

クラス概要

RarEntry
final class RarEntry {
/* 定数 */
const int RarEntry::HOST_MSDOS = 0;
const int RarEntry::HOST_OS2 = 1;
const int RarEntry::HOST_WIN32 = 2;
const int RarEntry::HOST_UNIX = 3;
const int RarEntry::HOST_MACOS = 4;
const int RarEntry::HOST_BEOS = 5;
const int RarEntry::ATTRIBUTE_WIN_READONLY = 1;
const int RarEntry::ATTRIBUTE_WIN_HIDDEN = 2;
const int RarEntry::ATTRIBUTE_WIN_SYSTEM = 4;
const int RarEntry::ATTRIBUTE_WIN_DIRECTORY = 16;
const int RarEntry::ATTRIBUTE_WIN_ARCHIVE = 32;
const int RarEntry::ATTRIBUTE_WIN_DEVICE = 64;
const int RarEntry::ATTRIBUTE_WIN_NORMAL = 128;
const int RarEntry::ATTRIBUTE_WIN_TEMPORARY = 256;
const int RarEntry::ATTRIBUTE_WIN_SPARSE_FILE = 512;
const int RarEntry::ATTRIBUTE_WIN_REPARSE_POINT = 1024;
const int RarEntry::ATTRIBUTE_WIN_COMPRESSED = 2048;
const int RarEntry::ATTRIBUTE_WIN_OFFLINE = 4096;
const int RarEntry::ATTRIBUTE_WIN_NOT_CONTENT_INDEXED = 8192;
const int RarEntry::ATTRIBUTE_WIN_ENCRYPTED = 16384;
const int RarEntry::ATTRIBUTE_WIN_VIRTUAL = 65536;
const int RarEntry::ATTRIBUTE_UNIX_WORLD_EXECUTE = 1;
const int RarEntry::ATTRIBUTE_UNIX_WORLD_WRITE = 2;
const int RarEntry::ATTRIBUTE_UNIX_WORLD_READ = 4;
const int RarEntry::ATTRIBUTE_UNIX_GROUP_EXECUTE = 8;
const int RarEntry::ATTRIBUTE_UNIX_GROUP_WRITE = 16;
const int RarEntry::ATTRIBUTE_UNIX_GROUP_READ = 32;
const int RarEntry::ATTRIBUTE_UNIX_OWNER_EXECUTE = 64;
const int RarEntry::ATTRIBUTE_UNIX_OWNER_WRITE = 128;
const int RarEntry::ATTRIBUTE_UNIX_OWNER_READ = 256;
const int RarEntry::ATTRIBUTE_UNIX_STICKY = 512;
const int RarEntry::ATTRIBUTE_UNIX_SETGID = 1024;
const int RarEntry::ATTRIBUTE_UNIX_SETUID = 2048;
const int RarEntry::ATTRIBUTE_UNIX_FINAL_QUARTET = 61440;
const int RarEntry::ATTRIBUTE_UNIX_FIFO = 4096;
const int RarEntry::ATTRIBUTE_UNIX_CHAR_DEV = 8192;
const int RarEntry::ATTRIBUTE_UNIX_DIRECTORY = 16384;
const int RarEntry::ATTRIBUTE_UNIX_BLOCK_DEV = 24576;
const int RarEntry::ATTRIBUTE_UNIX_REGULAR_FILE = 32768;
const int RarEntry::ATTRIBUTE_UNIX_SYM_LINK = 40960;
const int RarEntry::ATTRIBUTE_UNIX_SOCKET = 49152;
/* メソッド */
public bool extract(
    string $dir,
    string $filepath = "",
    string $password = NULL,
    bool $extended_data = false
)
public int getAttr()
public string getCrc()
public string getFileTime()
public int getHostOs()
public int getMethod()
public string getName()
public int getPackedSize()
public resourcefalse getStream(string $password = ?)
public int getUnpackedSize()
public int getVersion()
public bool isDirectory()
public bool isEncrypted()
public string __toString()
}

定義済み定数

RarEntry::HOST_MSDOS

If the return value of RarEntry::getHostOs equals this constant, MS-DOS was used to add this entry. Use instead of RAR_HOST_MSDOS.

RarEntry::HOST_OS2

If the return value of RarEntry::getHostOs equals this constant, OS/2 was used to add this entry. Intended to replace RAR_HOST_OS2.

RarEntry::HOST_WIN32

If the return value of RarEntry::getHostOs equals this constant, Microsoft Windows was used to add this entry. Intended to replace RAR_HOST_WIN32.

RarEntry::HOST_UNIX

If the return value of RarEntry::getHostOs equals this constant, an unspecified UNIX OS was used to add this entry. Intended to replace RAR_HOST_UNIX.

RarEntry::HOST_MACOS

If the return value of RarEntry::getHostOs equals this constant, Mac OS was used to add this entry.

RarEntry::HOST_BEOS

If the return value of RarEntry::getHostOs equals this constant, BeOS was used to add this entry. Intended to replace RAR_HOST_BEOS.

RarEntry::ATTRIBUTE_WIN_READONLY

Bit that represents a Windows entry with a read-only attribute. To be used with RarEntry::getAttr on entries whose host OS is Microsoft Windows.

RarEntry::ATTRIBUTE_WIN_HIDDEN

Bit that represents a Windows entry with a hidden attribute. To be used with RarEntry::getAttr on entries whose host OS is Microsoft Windows.

RarEntry::ATTRIBUTE_WIN_SYSTEM

Bit that represents a Windows entry with a system attribute. To be used with RarEntry::getAttr on entries whose host OS is Microsoft Windows.

RarEntry::ATTRIBUTE_WIN_DIRECTORY

Bit that represents a Windows entry with a directory attribute (entry is a directory). To be used with RarEntry::getAttr on entries whose host OS is Microsoft Windows. See also RarEntry::isDirectory, which also works with entries that were not added in WinRAR.

RarEntry::ATTRIBUTE_WIN_ARCHIVE

Bit that represents a Windows entry with an archive attribute. To be used with RarEntry::getAttr on entries whose host OS is Microsoft Windows.

RarEntry::ATTRIBUTE_WIN_DEVICE

Bit that represents a Windows entry with a device attribute. To be used with RarEntry::getAttr on entries whose host OS is Microsoft Windows.

RarEntry::ATTRIBUTE_WIN_NORMAL

Bit that represents a Windows entry with a normal file attribute (entry is NOT a directory). To be used with RarEntry::getAttr on entries whose host OS is Microsoft Windows. See also RarEntry::isDirectory, which also works with entries that were not added in WinRAR.

RarEntry::ATTRIBUTE_WIN_TEMPORARY

Bit that represents a Windows entry with a temporary attribute. To be used with RarEntry::getAttr on entries whose host OS is Microsoft Windows.

RarEntry::ATTRIBUTE_WIN_SPARSE_FILE

Bit that represents a Windows entry with a sparse file attribute (file is an NTFS sparse file). To be used with RarEntry::getAttr on entries whose host OS is Microsoft Windows.

RarEntry::ATTRIBUTE_WIN_REPARSE_POINT

Bit that represents a Windows entry with a reparse point attribute (entry is an NTFS reparse point, e.g. a directory junction or a mount file system). To be used with RarEntry::getAttr on entries whose host OS is Microsoft Windows.

RarEntry::ATTRIBUTE_WIN_COMPRESSED

Bit that represents a Windows entry with a compressed attribute (NTFS only). To be used with RarEntry::getAttr on entries whose host OS is Microsoft Windows.

RarEntry::ATTRIBUTE_WIN_OFFLINE

Bit that represents a Windows entry with an offline attribute (entry is offline and not accessible). To be used with RarEntry::getAttr on entries whose host OS is Microsoft Windows.

RarEntry::ATTRIBUTE_WIN_NOT_CONTENT_INDEXED

Bit that represents a Windows entry with a not content indexed attribute (entry is to be indexed). To be used with RarEntry::getAttr on entries whose host OS is Microsoft Windows.

RarEntry::ATTRIBUTE_WIN_ENCRYPTED

Bit that represents a Windows entry with an encrypted attribute (NTFS only). To be used with RarEntry::getAttr on entries whose host OS is Microsoft Windows.

RarEntry::ATTRIBUTE_WIN_VIRTUAL

Bit that represents a Windows entry with a virtual attribute. To be used with RarEntry::getAttr on entries whose host OS is Microsoft Windows.

RarEntry::ATTRIBUTE_UNIX_WORLD_EXECUTE

Bit that represents a UNIX entry that is world executable. To be used with RarEntry::getAttr on entries whose host OS is UNIX.

RarEntry::ATTRIBUTE_UNIX_WORLD_WRITE

Bit that represents a UNIX entry that is world writable. To be used with RarEntry::getAttr on entries whose host OS is UNIX.

RarEntry::ATTRIBUTE_UNIX_WORLD_READ

Bit that represents a UNIX entry that is world readable. To be used with RarEntry::getAttr on entries whose host OS is UNIX.

RarEntry::ATTRIBUTE_UNIX_GROUP_EXECUTE

Bit that represents a UNIX entry that is group executable. To be used with RarEntry::getAttr on entries whose host OS is UNIX.

RarEntry::ATTRIBUTE_UNIX_GROUP_WRITE

Bit that represents a UNIX entry that is group writable. To be used with RarEntry::getAttr on entries whose host OS is UNIX.

RarEntry::ATTRIBUTE_UNIX_GROUP_READ

Bit that represents a UNIX entry that is group readable. To be used with RarEntry::getAttr on entries whose host OS is UNIX.

RarEntry::ATTRIBUTE_UNIX_OWNER_EXECUTE

Bit that represents a UNIX entry that is owner executable. To be used with RarEntry::getAttr on entries whose host OS is UNIX.

RarEntry::ATTRIBUTE_UNIX_OWNER_WRITE

Bit that represents a UNIX entry that is owner writable. To be used with RarEntry::getAttr on entries whose host OS is UNIX.

RarEntry::ATTRIBUTE_UNIX_OWNER_READ

Bit that represents a UNIX entry that is owner readable. To be used with RarEntry::getAttr on entries whose host OS is UNIX.

RarEntry::ATTRIBUTE_UNIX_STICKY

Bit that represents the UNIX sticky bit. To be used with RarEntry::getAttr on entries whose host OS is UNIX.

RarEntry::ATTRIBUTE_UNIX_SETGID

Bit that represents the UNIX setgid attribute. To be used with RarEntry::getAttr on entries whose host OS is UNIX.

RarEntry::ATTRIBUTE_UNIX_SETUID

Bit that represents the UNIX setuid attribute. To be used with RarEntry::getAttr on entries whose host OS is UNIX.

RarEntry::ATTRIBUTE_UNIX_FINAL_QUARTET

Mask to isolate the last four bits (nibble) of UNIX attributes (_S_IFMT, the type of file mask). To be used with RarEntry::getAttr on entries whose host OS is UNIX and with the constants RarEntry::ATTRIBUTE_UNIX_FIFO, RarEntry::ATTRIBUTE_UNIX_CHAR_DEV, RarEntry::ATTRIBUTE_UNIX_DIRECTORY, RarEntry::ATTRIBUTE_UNIX_BLOCK_DEV, RarEntry::ATTRIBUTE_UNIX_REGULAR_FILE, RarEntry::ATTRIBUTE_UNIX_SYM_LINK and RarEntry::ATTRIBUTE_UNIX_SOCKET.

RarEntry::ATTRIBUTE_UNIX_FIFO

Unix FIFOs will have attributes whose last four bits have this value. To be used with RarEntry::getAttr on entries whose host OS is UNIX and with the constant RarEntry::ATTRIBUTE_UNIX_FINAL_QUARTET.

RarEntry::ATTRIBUTE_UNIX_CHAR_DEV

Unix character devices will have attributes whose last four bits have this value. To be used with RarEntry::getAttr on entries whose host OS is UNIX and with the constant RarEntry::ATTRIBUTE_UNIX_FINAL_QUARTET.

RarEntry::ATTRIBUTE_UNIX_DIRECTORY

Unix directories will have attributes whose last four bits have this value. To be used with RarEntry::getAttr on entries whose host OS is UNIX and with the constant RarEntry::ATTRIBUTE_UNIX_FINAL_QUARTET. See also RarEntry::isDirectory, which also works with entries that were added in other operating systems.

RarEntry::ATTRIBUTE_UNIX_BLOCK_DEV

Unix block devices will have attributes whose last four bits have this value. To be used with RarEntry::getAttr on entries whose host OS is UNIX and with the constant RarEntry::ATTRIBUTE_UNIX_FINAL_QUARTET.

RarEntry::ATTRIBUTE_UNIX_REGULAR_FILE

Unix regular files (not directories) will have attributes whose last four bits have this value. To be used with RarEntry::getAttr on entries whose host OS is UNIX and with the constant RarEntry::ATTRIBUTE_UNIX_FINAL_QUARTET. See also RarEntry::isDirectory, which also works with entries that were added in other operating systems.

Unix symbolic links will have attributes whose last four bits have this value. To be used with RarEntry::getAttr on entries whose host OS is UNIX and with the constant RarEntry::ATTRIBUTE_UNIX_FINAL_QUARTET.

RarEntry::ATTRIBUTE_UNIX_SOCKET

Unix sockets will have attributes whose last four bits have this value. To be used with RarEntry::getAttr on entries whose host OS is UNIX and with the constant RarEntry::ATTRIBUTE_UNIX_FINAL_QUARTET.

RarException クラス

はじめに

このクラスの役割は、RAR 拡張モジュールの関数やメソッドからスローされた例外を表す型となることと staticメソッドを使ってエラーの詳細 (例外がスローされたのか、 それとも警告が発生しただけなのかなど) を得ることのふたつです。

次のエラーコードを使います。

  • -1 - UnRAR ライブラリ以外のエラー
  • 11 - メモリの不足
  • 12 - データ不良
  • 13 - アーカイブ不良
  • 14 - 未知のフォーマット
  • 15 - ファイルオープンエラー
  • 16 - ファイル作成エラー
  • 17 - ファイルクローズエラー
  • 18 - 読み込みエラー
  • 19 - 書き込みエラー
  • 20 - バッファ不足
  • 21 - 未知の RAR エラー
  • 22 - パスワードが要求されているのに指定しなかった

クラス概要

RarException
final class RarException extends Exception {
/* メソッド */
public static bool isUsingExceptions()
public static void setUsingExceptions(bool $using_exceptions)
/* 継承したメソッド */
final public string Exception::getMessage()
final public Throwablenull Exception::getPrevious()
final public int Exception::getCode()
final public string Exception::getFile()
final public int Exception::getLine()
final public array Exception::getTrace()
final public string Exception::getTraceAsString()
public string Exception::__toString()
private void Exception::__clone()
}