/
githubmirror
/
magento2
Обзор
Документация
Войти
/
githubmirror
/
magento2
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
2.4-develop
lib/internal/Magento/Framework/Archive/Helper/File/Gz.php
69 строк
2 KB
Alexandra Zota
ACP2E-4019: CE copyright updates for 2.4.9-beta1
22 окт 2025, 17:47
22 окт 2025, 17:47
1b769b7
Код
Авторство
О чём код?
<?php /** * Copyright 2014 Adobe * All Rights Reserved. */ /** * Helper class that simplifies gz files stream reading and writing */ namespace Magento\Framework\Archive\Helper\File; class Gz extends \Magento\Framework\Archive\Helper\File { /** * {@inheritdoc} * @throws \RuntimeException */ protected function _open($mode) { if (!extension_loaded('zlib')) { throw new \RuntimeException('PHP extension zlib is required.'); } $this->_fileHandler = gzopen($this->_filePath, $mode); if (false === $this->_fileHandler) { throw new \Magento\Framework\Exception\LocalizedException( new \Magento\Framework\Phrase('The "%1" file failed to open.', [$this->_filePath]) ); } } /** * {@inheritdoc} */ protected function _write($data) { $result = gzwrite($this->_fileHandler, $data); if (empty($result) && !empty($data)) { throw new \Magento\Framework\Exception\LocalizedException( new \Magento\Framework\Phrase('The data failed to write to "%1".', [$this->_filePath]) ); } } /** * {@inheritdoc} */ protected function _read($length) { return gzread($this->_fileHandler, $length); } /** * {@inheritdoc} */ protected function _eof() { return gzeof($this->_fileHandler); } /** * {@inheritdoc} */ protected function _close() { gzclose($this->_fileHandler); } }