final class RarEntry (View source)

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

Constants

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}.

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}.

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}

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}.

HOST_MACOS

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

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}.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

ATTRIBUTE_UNIX_STICKY

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

ATTRIBUTE_UNIX_SETGID

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

ATTRIBUTE_UNIX_SETUID

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

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}, {@see RarEntry::ATTRIBUTE_UNIX_DIRECTORY}, {RarEntry::ATTRIBUTE_UNIX_BLOCK_DEV}, {@see RarEntry::ATTRIBUTE_UNIX_REGULAR_FILE}, {RarEntry::ATTRIBUTE_UNIX_SYM_LINK} and {RarEntry::ATTRIBUTE_UNIX_SOCKET}.

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}.

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}.

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.

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}.

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.

ATTRIBUTE_UNIX_SYM_LINK

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}.

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}.

Methods

bool
extract(string $dir, string $filepath = "", string $password = null, bool $extended_data = false)

Extract entry from the archive

int|false
getAttr()

Get attributes of the entry

string|false
getCrc()

Get CRC of the entry

string|false
getFileTime()

Get entry last modification time

int|false
getHostOs()

Get entry host OS

int|false
getMethod()

Get pack method of the entry

string|false
getName()

Get name of the entry

int|false
getPackedSize()

Get packed size of the entry

resource|false
getStream(string $password = '')

Get file handler for entry

int|false
getUnpackedSize()

Get unpacked size of the entry

int|false
getVersion()

Get minimum version of RAR program required to unpack the entry

bool
isDirectory()

Test whether an entry represents a directory

bool
isEncrypted()

Test whether an entry is encrypted

string
__toString()

Get text representation of entry

Details

bool extract(string $dir, string $filepath = "", string $password = null, bool $extended_data = false)

Extract entry from the archive

extracts the entry's data. It will create new file in the specified dir with the name identical to the entry's name, unless the second argument is specified.

Parameters

string $dir

Path to the directory where files should be extracted. This parameter is considered if and only if filepath is not. If both parameters are empty an extraction to the current directory will be attempted.

string $filepath

Path (relative or absolute) containing the directory and filename of the extracted file. This parameter overrides both the parameter dir and the original file name.

string $password

The password used to encrypt this entry. If the entry is not encrypted, this value will not be used and can be omitted. If this parameter is omitted and the entry is encrypted, the password given to rar_open(), if any, will be used. If a wrong password is given, either explicitly or implicitly via rar_open(), CRC checking will fail and this method will fail and return FALSE. If no password is given and one is required, this method will fail and return FALSE. You can check whether an entry is encrypted with {\RarEntry::isEncrypted()}.

bool $extended_data

If TRUE, extended information such as NTFS ACLs and Unix owner information will be set in the extract files, as long as it's present in the archive.

Return Value

bool

TRUE on success or FALSE on failure

int|false getAttr()

Get attributes of the entry

Returns the OS-dependent attributes of the archive entry

Return Value

int|false

the attributes or FALSE on error

string|false getCrc()

Get CRC of the entry

Returns an hexadecimal string representation of the CRC of the archive entry.

Return Value

string|false

the CRC of the archive entry or FALSE on error

string|false getFileTime()

Get entry last modification time

Return Value

string|false

entry last modification time as string in format YYYY-MM-DD HH:II:SS, or FALSE on errors

int|false getHostOs()

Get entry host OS

Returns the code of the host OS of the archive entry

Return Value

int|false

the code of the host OS, or FALSE on error

int|false getMethod()

Get pack method of the entry

returns number of the method used when adding current archive entry

Return Value

int|false

the method number or FALSE on error

string|false getName()

Get name of the entry

Returns the name (with path) of the archive entry.

Return Value

string|false

the entry name as a string, or FALSE on error.

int|false getPackedSize()

Get packed size of the entry

Return Value

int|false

the packed size, or FALSE on error

resource|false getStream(string $password = '')

Get file handler for entry

Returns a file handler that supports read operations. This handler provides on-the-fly decompression for this entry. The handler is not invalidated by calling {\rar_close()}.

Parameters

string $password

The password used to encrypt this entry. If the entry is not encrypted, this value will not be used and can be omitted. If this parameter is omitted and the entry is encrypted, the password given to {\rar_open()}, if any, will be used. If a wrong password is given, either explicitly or implicitly via {\rar_open()}, this method's resulting stream will produce wrong output. If no password is given and one is required, this method will fail and return FALSE. You can check whether an entry is encrypted with {\RarEntry::isEncrypted()}.

Return Value

resource|false

file handler or FALSE on failure

int|false getUnpackedSize()

Get unpacked size of the entry

Return Value

int|false

the unpacked size, or FALSE on error

int|false getVersion()

Get minimum version of RAR program required to unpack the entry

Returns minimum version of RAR program (e.g. WinRAR) required to unpack the entry. It is encoded as 10 * major version + minor version.

Return Value

int|false

the version or FALSE on error

bool isDirectory()

Test whether an entry represents a directory

Return Value

bool

TRUE if this entry is a directory and FALSE otherwise.

bool isEncrypted()

Test whether an entry is encrypted

Return Value

bool

TRUE if the current entry is encrypted and FALSE otherwise

string __toString()

Get text representation of entry

Returns a textual representation for this entry. It includes whether the entry is a file or a directory (symbolic links and other special objects will be treated as files), the UTF-8 name of the entry and its CRC. The form and content of this representation may be changed in the future, so they cannot be relied upon.

Return Value

string

A textual representation for the entry