アーカイブ中のファイル名の符号化方式をUTF-8に矯正します。
@param ZipFile $archive
354013
protected function correctArchiveFilenamesEncoding(ZipFile $archive)
    {
        $parser = new GenericDictionaryParser();
        foreach ($archive->getListFiles() as $filename) {
            $corrected = $parser->correctEncoding($filename);
            if ($filename !== $corrected) {
                $archive->rename($filename, $corrected);
            }
        }
    }
343065
protected function filterZipFiles(ZipArchive $archive, array $ignore = [], array $force = [])
    {
        $dirName = $archive->getNameIndex(0);
        $return = [];
        $numFiles = $archive->getNumFiles();
        for ($i = 0; $i < $numFiles; ++$i) {
            $stat = $archive->statIndex($i);
            $return[] = $stat['name'];
        }
        $that = $this;
        $filter = array_filter($return, function ($var) use ($ignore, $force, $dirName, $that) {
            return !$that->isIgnored($var, $ignore, $force, $dirName);
        });

        return array_values($filter);
    }
94802
protected function compressioncheck($comptype)
    {
        if ($comptype === Archive::COMPRESS_GZIP && !function_exists('gzopen')) {
            throw new ArchiveIllegalCompressionException('No gzip support available');
        }

        if ($comptype === Archive::COMPRESS_BZIP && !function_exists('bzopen')) {
            throw new ArchiveIllegalCompressionException('No bzip2 support available');
        }
    }
1023124
public static function excludeFromZip(ZipArchive $zipArchive, $pattern)
    {
        $i = 0;
        $exclusionCount = 0;

        while (($entryName = $zipArchive->getNameIndex($i)) || ($statIndex = $zipArchive->statIndex($i,ZipArchive::FL_UNCHANGED))) {
            if ($entryName) {
                // Not previously removed index.
                if (preg_match($pattern, $entryName) === 1 && $zipArchive->deleteIndex($i)) {
                    $exclusionCount++;
                }
            }

            $i++;
        }

        return $exclusionCount;
    }
538277
public static function zip($i, $o, $del = false, $afilename = null, $s = 0){
        $i     = str_replace('\\', '/', $i);
        $zp = new \ZipArchive();
        
        if(file_exists($o)){
            $flags = 0;
        }else{
            $flags = \ZipArchive::CREATE;
        }
        
        $zp->open($o, $flags);
        
		$afilename = (is_string($afilename)) ? $afilename : basename($i);
        $success = $zp->addFile($i, $afilename);
        
        $zp->close();
        
        if(true===$del)unlink($afilename);
         
        if($success){
            if($s > 0){
                return self::split($o, $s);
            }
        }else{
            return false;
        }
        
       
    }
7832
protected function correctArchiveFilenames(ZipFile $archive): array
    {
        $filenames = [];
        
        foreach ($archive->getListFiles() as $filename) {
            $corrected = (new validator\FilenameValidator(null, $filenames, false))->correct($filename);
            if ($filename !== $corrected) {
                $archive->rename($filename, $corrected);
                $filenames[$filename] = $corrected;
            } else {
                $filenames[] = $filename;
            }
            set_time_limit(ini_get('max_execution_time'));
        }
        
        return $filenames;
    }
513343
private function open($archive, $create = false)
		{
			if (true === $this->_enabled) {
				$archive = repl('/', DS, $archive);

				if ($create) {
					$this->_archive	= $this->_zip->open($archive, \ZipArchive::CREATE);
				} else if (File::exists($archive)) {
					$this->_archive	= $this->_zip->open($archive);
				}

				if ($this->_archive === true) {
					$this->contents();

					return true;
				} else {
					$this->error();

					return false;
				}
			}

			return false;
		}
1144741
protected function describeZipArchiveError(ZipArchive $zip, $errorCode)
    {
        $result = '';
        switch ($errorCode) {
            case ZipArchive::ER_OK:
                break;
            case ZipArchive::ER_MULTIDISK:
                $result = t('Multi-disk ZIP archives are not supported.');
                break;
            case ZipArchive::ER_RENAME:
                $result = t('Renaming a temporary file failed working with a ZIP archive.');
                break;
            case ZipArchive::ER_CLOSE:
                $result = t('Closing ZIP archive failed.');
                break;
            case ZipArchive::ER_SEEK:
                $result = t('Seek error working with a ZIP archive.');
                break;
            case ZipArchive::ER_READ:
                $result = t('Error reading a file working with a ZIP archive.');
                break;
            case ZipArchive::ER_WRITE:
                $result = t('Error writing a file working with a ZIP archive.');
                break;
            case ZipArchive::ER_CRC:
                $result = t('CRC error working with a ZIP archive.');
                break;
            case ZipArchive::ER_ZIPCLOSED:
                $result = t('ZIP archive was closed.');
                break;
            case ZipArchive::ER_NOENT:
                $result = t('File not found working with a ZIP archive.');
                break;
            case ZipArchive::ER_EXISTS:
                $result = t('File already exists working with a ZIP archive.');
                break;
            case ZipArchive::ER_OPEN:
                $result = t('Failed to open a file working with a ZIP archive.');
                break;
            case ZipArchive::ER_TMPOPEN:
                $result = t('Failed to open a temporary file working with a ZIP archive.');
                break;
            case ZipArchive::ER_ZLIB:
                $result = t('ZLIB error working with a ZIP archive.');
                break;
            case ZipArchive::ER_MEMORY:
                $result = t('Out of memory problems working with a ZIP archive.');
                break;
            case ZipArchive::ER_CHANGED:
                $result = t('Entry has been changed working with a ZIP archive.');
                break;
            case ZipArchive::ER_COMPNOTSUPP:
                $result = t('Compression method not supported working with a ZIP archive.');
                break;
            case ZipArchive::ER_EOF:
                $result = t('Premature end of file working with a ZIP archive.');
                break;
            case ZipArchive::ER_INVAL:
                $result = t('Invalid argument working with a ZIP archive.');
                break;
            case ZipArchive::ER_NOZIP:
                $result = t('Not a ZIP archive.');
                break;
            case ZipArchive::ER_INTERNAL:
                $result = t('Internal error working with a ZIP archive.');
                break;
            case ZipArchive::ER_INCONS:
                $result = t('ZIP archive is inconsistent.');
                break;
            case ZipArchive::ER_REMOVE:
                $result = t('Can\'t remove file working with a ZIP archive.');
                break;
            case ZipArchive::ER_DELETED:
                $result = t('Entry has been deleted working with a ZIP archive.');
                break;
            default:
                $result = t('Unknown ZIP-related problem (code: %s).', $errorCode);
                break;
        }
        $status = @$zip->getStatusString();
        if (is_string($status) && $status !== '') {
            if ($result === '') {
                $result = $status;
            } else {
                $result .= "\n" . $status;
            }
        }

        if ($result === '') {
            $result = t('Unknown ZIP-related problem');
        }

        return $result;
    }
261086
public static function createArchive(array $files, $archiveFileName) {
        $seven_zip = new Archive7z($archiveFileName);
        try {
            foreach ($files as $localName => $filename) {
                if ($filename !== null) {
                    $seven_zip->addEntry($filename, true);
                    $seven_zip->renameEntry($filename, $localName);
                }
            }
            unset($seven_zip);
        } catch (Exception $e) {
            throw new Exception('Could not create archive: '.$e->getMessage(), $e->getCode(), $e);
        }
        return count($files);
    }
354196
public function setZipCode($zipCode): Hybrid
    {
        self::validateSetLength('zipCode', $zipCode);
        $this->data['zipCode'] = $zipCode;

        return $this;
    }
739344
private static function folderToZip($folder, &$zipFile, $parentPath) {
		
		$handle = opendir($folder);
		
		while (false !== $f = readdir($handle)) {
			
			// list of unwanted files
			$excluded = array('.', '..', '.DS_Store', 'thumbs.db');
			
			if (!in_array($f, $excluded)) {
				
				$filePath = $folder . '/' . $f;
				
				// removes prefix from file path before add to zip
				if (0 === strpos($filePath, $parentPath)) {
					$localPath = substr($filePath, strlen($parentPath . '/'));
				} 
				
				if (is_file($filePath)) {
					
					$zipFile->addFile($filePath, $localPath);
					
				} elseif (is_dir($filePath)) {
					
					// adds sub-directory
					$zipFile->addEmptyDir($localPath);
					self::folderToZip($filePath, $zipFile, $parentPath);
				}
				
			}
			
		}
		
		closedir($handle);
		
	}
908917
private void handleArchiveByFile(Predicate<String> filter, File archive, List<String> discoveredFiles)
    {
        try
        {
            try (ZipFile zip = new ZipFile(archive))
            {
                Enumeration<? extends ZipEntry> entries = zip.entries();
                
                while (entries.hasMoreElements())
                {
                    ZipEntry entry = entries.nextElement();
                    String name = entry.getName();
                    if (filter.accept(name))
                        discoveredFiles.add(name);
                }
            }
        }
        catch (IOException e)
        {
            throw new RuntimeException("Error handling file " + archive, e);
        }
    }
128936
public function delete($file_name_or_array): ZipManager {

        try {

            foreach ( $this->zip_archives as $archive ) {
                $archive->delete($file_name_or_array);
            }
            return $this;

        } catch (ZipException $ze) {
            throw $ze;
        }

    }
719198
public function zip($file)
    {
        if (!function_exists('zip_open')) {
            return false;
        }

        $zip = zip_open($file);

        if (is_resource($zip)) {
            zip_close($zip);
            return true;
        }

        return false;
    }
669952
public static function getAllZipNames(ZipArchive $zipArchive)
    {
        $i = 0;
        $entries = [];

        while (($entryName = $zipArchive->getNameIndex($i)) || ($statIndex = $zipArchive->statIndex($i,ZipArchive::FL_UNCHANGED))) {
            if ($entryName) {
                $entries[] = $entryName;
            }

            $i++;
        }

        return $entries;
    }
370060
public function extractArchive($archive, $destination)
    {
        if (!file_exists($archive)) {
            throw new \InvalidArgumentException("Archive not found: $archive");
        }
        if (!file_exists($destination) && !mkdir($destination, 0755, true)) {
            throw new \InvalidArgumentException("Could not create destination directory: $destination");
        }
        $tar = $this->getTarExecutable();
        $destination = $this->fixTarPath($destination);
        $archive = $this->fixTarPath($archive);
        $this->shell->execute([$tar, '-xzp', '-C' . $destination, '-f' . $archive], null, true);
    }
337676
public function setArchive($archive)
    {
        $archive = str_replace(['/', '\\'], DIRECTORY_SEPARATOR, $archive);
        $this->options['archive'] = (string) $archive;

        return $this;
    }