Skip to the content.

This file describes all UnifiedArchive API.

TOC

UnifiedArchive is represented by few basic classes under \wapmorgan\UnifiedArchive namespace:

  1. Formats keeps information about formats support and specific format functions.
  2. Abilities list.
  3. UnifiedArchive - represents an archive and provides related functions.
  4. ArchiveEntry - represents information about a specific file from archive. This object can be obtained by call UnifiedArchive->getFileData() method.

Formats

$format should be one of Formats constants (such as Formats::ZIP and so on). Full list of constants provided in the appendix of this document. If you want to enabled specific format support, you need to install an additional program or php extension. List of extensions that should be installed can be obtained by executing built-in cam: ./vendor/bin/cam system:drivers

All methods are static.

Method Arguments Result Description
Formats::detectArchiveFormat string $archiveFileName, bool $contentCheck = true ?string Detects a format of given archive by file name and content (when $contentCheck = true). Returns one of Formats constant or null if format is not detected.
Formats::getFormatMimeType string $format ?string Returns mime type for passed format. Returns null if not found.
Formats::can string $format, int $ability boolean Check if any driver supports passed ability for passed format
Formats::canOpen, Formats::canStream, Formats::canCreate, Formats::canAppend, Formats::canUpdate, Formats::canEncrypt string $format boolean Tests if an archive format can be opened/created/appended (add)/updated (delete)/created encrypted by any driver with current system and php configuration.

Formats list

Abilities

UnifiedArchive

Archive opening

Archive information

All following methods is intended to be called to UnifiedArchive instance.

Method Result Description
UnifiedArchive::getFormat() string Returns format of archive as one of Formats constants.
UnifiedArchive::getMimeType() string/null Returns mime type of archive.
UnifiedArchive::getSize() int Returns size of archive file in bytes.
UnifiedArchive::getCompressedSize() int Returns size of all stored files in archive with archive compression in bytes. This can be used to measure efficiency of format compression.
UnifiedArchive::getOriginalSize() int Returns size of all stored files in archive without compression in bytes. This can be used to measure size that extracted files will use.
UnifiedArchive::countFiles() int Returns number of files stored in an archive.
UnifiedArchive::getComment() ?string Returns comment of archive or null (if not supported nor present).

Archive content

Archive modification

Making an archive

ArchiveEntry

The class represents a file from archive as result of a call to UnifiedArchive::getFileData(string $fileName). It contains fields with file information: