Skip to the content.

This file describes all UnifiedArchive API.

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

  1. Formats keeps information about formats support and specific format functions.
  2. UnifiedArchive - represents an archive and provides related functions.
  3. ArchiveEntry - represents information about a specific file from archive. This object can be obtained by call to one of UnifiedArchive methods.

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/false Detects a format of given archive $archiveFileName. Checks file name and file content (if $contentCheck = true). Returns one of Formats constant or false if format is not detected.
Formats::canOpen string $format boolean Tests if an archive format can be opened by any driver with current system and php configuration.
Formats::canStream string $format boolean Tests if a specified archive can be streamed (getFileStream).
Formats::canCreate string $format boolean Tests if an archive format can be created by any driver with current system and php configuration.
Formats::canAppend string $format boolean Tests if an archive format can be appended (add).
Formats::canUpdate string $format boolean Tests if an archive format can be updated (delete).
Formats::canEncrypt string $format boolean Tests if an archive format can be encrypted or opened with encryption by any driver with new files.
Formats::checkFormatSupportAbility string $format, int $ability boolean Check if any driver supports passed ability for passed format
Formats::getFormatMimeType string $format string/false Returns mime type for passed format. Returns false if not found.

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/false 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:

Formats list