2026-03-30 14:54:57 +07:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace Safe;
|
|
|
|
|
|
|
|
|
|
use Safe\Exceptions\ZipException;
|
|
|
|
|
|
|
|
|
|
/**
|
2026-04-18 20:32:18 +07:00
|
|
|
* @param resource $zip_entry
|
2026-03-30 14:54:57 +07:00
|
|
|
* @throws ZipException
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
function zip_entry_close($zip_entry): void
|
|
|
|
|
{
|
|
|
|
|
error_clear_last();
|
|
|
|
|
$safeResult = \zip_entry_close($zip_entry);
|
|
|
|
|
if ($safeResult === false) {
|
|
|
|
|
throw ZipException::createFromPhpError();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2026-04-18 20:32:18 +07:00
|
|
|
* @param resource $zip_entry
|
|
|
|
|
* @return int
|
2026-03-30 14:54:57 +07:00
|
|
|
* @throws ZipException
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
function zip_entry_compressedsize($zip_entry): int
|
|
|
|
|
{
|
|
|
|
|
error_clear_last();
|
|
|
|
|
$safeResult = \zip_entry_compressedsize($zip_entry);
|
|
|
|
|
if ($safeResult === false) {
|
|
|
|
|
throw ZipException::createFromPhpError();
|
|
|
|
|
}
|
|
|
|
|
return $safeResult;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2026-04-18 20:32:18 +07:00
|
|
|
* @param resource $zip_entry
|
|
|
|
|
* @return string
|
2026-03-30 14:54:57 +07:00
|
|
|
* @throws ZipException
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
function zip_entry_compressionmethod($zip_entry): string
|
|
|
|
|
{
|
|
|
|
|
error_clear_last();
|
|
|
|
|
$safeResult = \zip_entry_compressionmethod($zip_entry);
|
|
|
|
|
if ($safeResult === false) {
|
|
|
|
|
throw ZipException::createFromPhpError();
|
|
|
|
|
}
|
|
|
|
|
return $safeResult;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2026-04-18 20:32:18 +07:00
|
|
|
* @param resource $zip_entry
|
|
|
|
|
* @return int
|
2026-03-30 14:54:57 +07:00
|
|
|
* @throws ZipException
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
function zip_entry_filesize($zip_entry): int
|
|
|
|
|
{
|
|
|
|
|
error_clear_last();
|
|
|
|
|
$safeResult = \zip_entry_filesize($zip_entry);
|
|
|
|
|
if ($safeResult === false) {
|
|
|
|
|
throw ZipException::createFromPhpError();
|
|
|
|
|
}
|
|
|
|
|
return $safeResult;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2026-04-18 20:32:18 +07:00
|
|
|
* @param resource $zip_entry
|
|
|
|
|
* @return string
|
2026-03-30 14:54:57 +07:00
|
|
|
* @throws ZipException
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
function zip_entry_name($zip_entry): string
|
|
|
|
|
{
|
|
|
|
|
error_clear_last();
|
|
|
|
|
$safeResult = \zip_entry_name($zip_entry);
|
|
|
|
|
if ($safeResult === false) {
|
|
|
|
|
throw ZipException::createFromPhpError();
|
|
|
|
|
}
|
|
|
|
|
return $safeResult;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2026-04-18 20:32:18 +07:00
|
|
|
* @param resource $zip_dp
|
|
|
|
|
* @param resource $zip_entry
|
|
|
|
|
* @param string $mode
|
2026-03-30 14:54:57 +07:00
|
|
|
* @throws ZipException
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
function zip_entry_open($zip_dp, $zip_entry, string $mode = "rb"): void
|
|
|
|
|
{
|
|
|
|
|
error_clear_last();
|
|
|
|
|
$safeResult = \zip_entry_open($zip_dp, $zip_entry, $mode);
|
|
|
|
|
if ($safeResult === false) {
|
|
|
|
|
throw ZipException::createFromPhpError();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2026-04-18 20:32:18 +07:00
|
|
|
* @param resource $zip_entry
|
|
|
|
|
* @param int $len
|
|
|
|
|
* @return string
|
2026-03-30 14:54:57 +07:00
|
|
|
* @throws ZipException
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
function zip_entry_read($zip_entry, int $len = 1024): string
|
|
|
|
|
{
|
|
|
|
|
error_clear_last();
|
|
|
|
|
$safeResult = \zip_entry_read($zip_entry, $len);
|
|
|
|
|
if ($safeResult === false) {
|
|
|
|
|
throw ZipException::createFromPhpError();
|
|
|
|
|
}
|
|
|
|
|
return $safeResult;
|
|
|
|
|
}
|