final class RarArchive implements Traversable (View source)

This class represents a RAR archive, which may be formed by several volumes (parts) and which contains a number of RAR entries (i.e., files, directories and other special objects such as symbolic links).

Objects of this class can be traversed, yielding the entries stored in the respective RAR archive. Those entries can also be obtained through {\RarArchive::getEntry} and {\RarArchive::getEntries}.

Methods

static RarArchive|false
open(string $filename, null|string $password = null, callable|null $volume_callback = null)

Open RAR archive

bool
close()

Close RAR archive and free all resources

string|null
getComment()

Get comment text from the RAR archive

RarEntry[]|false
getEntries()

Get full list of entries from the RAR archive

RarEntry|false
getEntry(string $entryname)

Get entry object from the RAR archive

bool
isBroken()

Test whether an archive is broken (incomplete)

bool
isSolid()

Check whether the RAR archive is solid

bool
setAllowBroken(bool $allow_broken)

Whether opening broken archives is allowed

string
__toString()

Get text representation

Details

static RarArchive|false open(string $filename, null|string $password = null, callable|null $volume_callback = null)

Open RAR archive

Parameters

string $filename

Path to the Rar archive

null|string $password

A plain password, if needed to decrypt the headers. It will also be used by default if encrypted files are found. Note that the files may have different passwords in respect to the headers and among them

callable|null $volume_callback

A function that receives one parameter – the path of the volume that was not found – and returns a string with the correct path for such volume or NULL if such volume does not exist or is not known. The programmer should ensure the passed function doesn't cause loops as this function is called repeatedly if the path returned in a previous call did not correspond to the needed volume. Specifying this parameter omits the notice that would otherwise be emitted whenever a volume is not found; an implementation that only returns NULL can therefore be used to merely omit such notices

Return Value

RarArchive|false

the requested RarArchive instance or FALSE on failure.

bool close()

Close RAR archive and free all resources

Return Value

bool

TRUE on success or FALSE on failure

string|null getComment()

Get comment text from the RAR archive

Return Value

string|null

the comment or NULL if there is none

RarEntry[]|false getEntries()

Get full list of entries from the RAR archive

Return Value

RarEntry[]|false

array of {\RarEntry} objects or FALSE on failure

RarEntry|false getEntry(string $entryname)

Get entry object from the RAR archive

Get entry object (file or directory) from the RAR archive

Parameters

string $entryname

Path to the entry within the RAR archive

Return Value

RarEntry|false

the matching RarEntry object or FALSE on failure

bool isBroken()

Test whether an archive is broken (incomplete)

This function determines whether an archive is incomplete, i.e., if a volume is missing or a volume is truncated.

Return Value

bool

Returns TRUE if the archive is broken, FALSE otherwise. This function may also return FALSE if the passed file has already been closed. The only way to tell the two cases apart is to enable exceptions with {\RarException::setUsingExceptions()}; however, this should be unnecessary as a program should not operate on closed files.

bool isSolid()

Check whether the RAR archive is solid

Check whether the RAR archive is solid. Individual file extraction is slower on solid archives

Return Value

bool

TRUE if the archive is solid, FALSE otherwise

bool setAllowBroken(bool $allow_broken)

Whether opening broken archives is allowed

This method defines whether broken archives can be read or all the operations that attempt to extract the archive entries will fail. Broken archives are archives for which no error is detected when the file is opened but an error occurs when reading the entries.

Parameters

bool $allow_broken

Whether to allow reading broken files (TRUE) or not (FALSE)

Return Value

bool

TRUE или FALSE в случае возникновения ошибки. It will only fail if the file has already been closed

string __toString()

Get text representation

Provides a string representation for this RarArchive object. It currently shows the full path name of the archive volume that was opened and whether the resource is valid or was already closed through a call to {[\RarArchive::close()}.

This](RarArchive.html) method may be used only for debugging purposes, as there are no guarantees as to which information the result contains or how it is formatted.

Return Value

string

A textual representation of this RarArchive object. The content of this representation is unspecified.