mirror of
https://github.com/Ne-Lexa/php-zip.git
synced 2025-01-17 20:58:22 +01:00
Optimize pack and unpack long fro PHP >= 5.6.3
This commit is contained in:
parent
4c6f27c269
commit
ac20d6fbf3
@ -18,7 +18,9 @@ class PackUtil
|
||||
*/
|
||||
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;
|
||||
$right = 0x00000000ffffffff;
|
||||
@ -36,7 +38,9 @@ class PackUtil
|
||||
*/
|
||||
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);
|
||||
return $unpack['a'] + ($unpack['b'] << 32);
|
||||
}
|
||||
|
@ -848,7 +848,7 @@ class ZipTest extends ZipTestCase
|
||||
'data' => CryptoUtil::randomBytes(255),
|
||||
'password' => CryptoUtil::randomBytes(255),
|
||||
'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' => [
|
||||
'data' => CryptoUtil::randomBytes(255),
|
||||
@ -1022,6 +1022,9 @@ class ZipTest extends ZipTestCase
|
||||
$zipFile->close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test zip alignment.
|
||||
*/
|
||||
public function testZipAlign()
|
||||
{
|
||||
$zipOutputFile = ZipOutputFile::create();
|
||||
@ -1042,7 +1045,7 @@ class ZipTest extends ZipTestCase
|
||||
if($result === null) return; // zip align not installed
|
||||
|
||||
// check not zip align
|
||||
self::assertFalse($result, false);
|
||||
self::assertFalse($result);
|
||||
|
||||
$zipFile = ZipFile::openFromFile($this->outputFilename);
|
||||
$zipOutputFile = ZipOutputFile::openFromZipFile($zipFile);
|
||||
@ -1062,6 +1065,7 @@ class ZipTest extends ZipTestCase
|
||||
|
||||
/**
|
||||
* Test support ZIP64 ext (slow test - normal).
|
||||
* Create > 65535 files in archive and open and extract to /dev/null.
|
||||
*/
|
||||
public function testCreateAndOpenZip64Ext()
|
||||
{
|
||||
@ -1078,8 +1082,7 @@ class ZipTest extends ZipTestCase
|
||||
|
||||
$zipFile = ZipFile::openFromFile($this->outputFilename);
|
||||
self::assertEquals($zipFile->count(), $countFiles);
|
||||
foreach ($zipFile->getListFiles() as $entry) {
|
||||
$zipFile->getEntryContent($entry);
|
||||
foreach ($zipFile as $entry => $content) {
|
||||
}
|
||||
$zipFile->close();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user