1
0
mirror of https://github.com/Ne-Lexa/php-zip.git synced 2025-10-19 17:18:12 +02:00

Completely rewritten code.

Implement read-only zip file - class \PhpZip\ZipFile, create and update zip file - \PhpZip\ZipOutputFile.
Supports ZIP64 ext, Traditional PKWARE Encryption, WinZip AES Encryption.
This commit is contained in:
Ne-Lexa
2016-09-26 12:04:38 +03:00
parent 5c23e588ff
commit 560a94c910
48 changed files with 7785 additions and 2905 deletions

View File

@@ -0,0 +1,44 @@
<?php
namespace PhpZip\Util;
use PhpZip\Exception\ZipException;
/**
* Pack util
*
* @author Ne-Lexa alexey@nelexa.ru
* @license MIT
*/
class PackUtil
{
/**
* @param int|string $longValue
* @return string
*/
public static function packLongLE($longValue)
{
// TODO test if (version_compare(PHP_VERSION, '5.6.3') >= 0) {return pack("P", $longValue);}
$left = 0xffffffff00000000;
$right = 0x00000000ffffffff;
$r = ($longValue & $left) >> 32;
$l = $longValue & $right;
return pack('VV', $l, $r);
}
/**
* @param string|int $value
* @return int
* @throws ZipException
*/
public static function unpackLongLE($value)
{
// TODO test 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);
}
}