Skip to content

1.1.3: Fixes, password, iteration

Choose a tag to compare

@wapmorgan wapmorgan released this 02 May 20:28
· 131 commits to master since this release

Changed format of $files in archiveFiles() and addFiles()

[
    '/var/www/log.txt',                // will be "/var/www/log.txt"
    'log2.txt' => '/var/www/log2.txt', // will be "/log2.txt"
    '/var/www/site',                   // will be "/var/www/site"
    'site2' => '/var/www/site2',       // will be "/site2"
]

Old format also works, but there can be a bad case. If you have /var/www/log2.txt and log2.txt (in current directory) and pass following:

[
'/var/www/log2.txt' => 'log2.txt',
]

it will archive log2.txt as /var/www/log2.txt in an archive (new behaviour).

New features:

  • Added Formats::canStream() to check if an archive files can be streamed.
  • Added ability to create archives, encrypted with password (only zip (Zip, SevenZip) and 7z (SevenZip)) - added nullable $password argument to:
    • UnifiedArchive::archiveFiles($fileOrFiles, $archiveName, $compressionLevel = BasicDriver::COMPRESSION_AVERAGE, $password = null)
    • UnifiedArchive::archiveFile($file, $archiveName, $compressionLevel = BasicDriver::COMPRESSION_AVERAGE, $password = null)
    • UnifiedArchive::archiveDirectory($directory, $archiveName, $compressionLevel = BasicDriver::COMPRESSION_AVERAGE, $password = null)
  • Added UnifiedArchive->getMimeType() to get mime type of archive.
  • Added UnifiedArchive->getComment() to get comment of an archive. Available only in Zip and Rar drivers, others return null.
  • Added UnifiedArchive->setComment(?string $comment) to set comment. Available only in Zip.
  • Added filter in UnifiedArcihve->getFileNames(). If works as fnmatch() does.
  • Added ability to iterate over archive and access files data as array:
$a = \wapmorgan\UnifiedArchive\UnifiedArchive::open('tests/archives/fixtures.7z');
foreach ($a as $file => $data) {
    echo $file.PHP_EOL;
 }

$file_data = $a['filename'];

Fixed:

  • Fixed SevenZip driver: disabled tar.gz, tar.bzip2 support as it isn't supported properly and described which formats driver can create, append, modify and encrypt.

Methods renamed (old exist, but marked as deprecated):

  • UnifiedArchive->getArchiveFormat -> UnifiedArchive->getFormat.
  • UnifiedArchive->getArchiveSize -> UnifiedArchive->getSize.
  • UnifiedArchive->countCompressedFilesSize -> UnifiedArchive->getCompressedSize.
  • UnifiedArchive->countUncompressedFilesSize -> UnifiedArchive->getOriginalSize.
  • UnifiedArchive->getFileResource -> UnifiedArchive->getFileStream.
  • UnifiedArchive->isFileExists -> UnifiedArchive->hasFile.