1
0
mirror of https://github.com/Ne-Lexa/php-zip.git synced 2025-07-18 22:51:11 +02:00

Merge branch 'release/2.0.2'

This commit is contained in:
Ne-Lexa
2016-09-26 18:07:38 +03:00
2 changed files with 13 additions and 6 deletions

View File

@@ -18,7 +18,9 @@ class PackUtil
*/ */
public static function packLongLE($longValue) public static function packLongLE($longValue)
{ {
// TODO test if (version_compare(PHP_VERSION, '5.6.3') >= 0) {return pack("P", $longValue);} if (version_compare(PHP_VERSION, '5.6.3') >= 0) {
return pack("P", $longValue);
}
$left = 0xffffffff00000000; $left = 0xffffffff00000000;
$right = 0x00000000ffffffff; $right = 0x00000000ffffffff;
@@ -36,7 +38,9 @@ class PackUtil
*/ */
public static function unpackLongLE($value) public static function unpackLongLE($value)
{ {
// TODO test if (version_compare(PHP_VERSION, '5.6.3') >= 0){ return current(unpack('P', $value)); } if (version_compare(PHP_VERSION, '5.6.3') >= 0) {
return current(unpack('P', $value));
}
$unpack = unpack('Va/Vb', $value); $unpack = unpack('Va/Vb', $value);
return $unpack['a'] + ($unpack['b'] << 32); return $unpack['a'] + ($unpack['b'] << 32);
} }

View File

@@ -848,7 +848,7 @@ class ZipTest extends ZipTestCase
'data' => CryptoUtil::randomBytes(255), 'data' => CryptoUtil::randomBytes(255),
'password' => CryptoUtil::randomBytes(255), 'password' => CryptoUtil::randomBytes(255),
'encryption_method' => ZipEntry::ENCRYPTION_METHOD_WINZIP_AES, 'encryption_method' => ZipEntry::ENCRYPTION_METHOD_WINZIP_AES,
'compression_method' => ZipEntry::METHOD_BZIP2, 'compression_method' => extension_loaded("bz2") ? ZipEntry::METHOD_BZIP2 : ZipEntry::METHOD_STORED,
], ],
'Not password.dat' => [ 'Not password.dat' => [
'data' => CryptoUtil::randomBytes(255), 'data' => CryptoUtil::randomBytes(255),
@@ -1022,6 +1022,9 @@ class ZipTest extends ZipTestCase
$zipFile->close(); $zipFile->close();
} }
/**
* Test zip alignment.
*/
public function testZipAlign() public function testZipAlign()
{ {
$zipOutputFile = ZipOutputFile::create(); $zipOutputFile = ZipOutputFile::create();
@@ -1042,7 +1045,7 @@ class ZipTest extends ZipTestCase
if($result === null) return; // zip align not installed if($result === null) return; // zip align not installed
// check not zip align // check not zip align
self::assertFalse($result, false); self::assertFalse($result);
$zipFile = ZipFile::openFromFile($this->outputFilename); $zipFile = ZipFile::openFromFile($this->outputFilename);
$zipOutputFile = ZipOutputFile::openFromZipFile($zipFile); $zipOutputFile = ZipOutputFile::openFromZipFile($zipFile);
@@ -1062,6 +1065,7 @@ class ZipTest extends ZipTestCase
/** /**
* Test support ZIP64 ext (slow test - normal). * Test support ZIP64 ext (slow test - normal).
* Create > 65535 files in archive and open and extract to /dev/null.
*/ */
public function testCreateAndOpenZip64Ext() public function testCreateAndOpenZip64Ext()
{ {
@@ -1078,8 +1082,7 @@ class ZipTest extends ZipTestCase
$zipFile = ZipFile::openFromFile($this->outputFilename); $zipFile = ZipFile::openFromFile($this->outputFilename);
self::assertEquals($zipFile->count(), $countFiles); self::assertEquals($zipFile->count(), $countFiles);
foreach ($zipFile->getListFiles() as $entry) { foreach ($zipFile as $entry => $content) {
$zipFile->getEntryContent($entry);
} }
$zipFile->close(); $zipFile->close();
} }