アーカイブ中のファイル名を矯正します。
@param ZipFile $archive
@return string[] ファイル名の一覧。矯正を行った場合は、キーに矯正前のファイル名を持ちます。
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;
    }
1024132
public static function build_zip(Application $app, Token $token, array $list, $zipFile)
    {
        if (isset($list['complete']) && $list['complete'] === true) {
            return $zipFile;
        }

        $files = $list['files'];

        $list['complete'] = false;

        $token->setData(serialize($list));
        $app['manipulator.token']->update($token);

        $toRemove = [];
        $archiveFiles = [];

        foreach ($files as $record) {
            if (isset($record["subdefs"])) {
                foreach ($record["subdefs"] as $o => $obj) {
                    $path = p4string::addEndSlash($obj["path"]) . $obj["file"];
                    if (is_file($path)) {
                        $name = $obj["folder"]
                            . $record["export_name"]
                            . $obj["ajout"]
                            . (isset($obj["exportExt"]) && trim($obj["exportExt"]) != '' ? '.' . $obj["exportExt"] : '');

                        $archiveFiles[$app['unicode']->remove_diacritics($name)] = $path;
                        if ($o == 'caption') {
                            if (!in_array(dirname($path), $toRemove)) {
                                $toRemove[] = dirname($path);
                            }
                            $toRemove[] = $path;
                        }
                    }
                }
            }
        }

        $app['zippy']->create($zipFile, $archiveFiles);

        $list['complete'] = true;

        $token->setData(serialize($list));
        $app['manipulator.token']->update($token);

        $app['filesystem']->remove($toRemove);
        $app['filesystem']->chmod($zipFile, 0760);

        return $zipFile;
    }
423905
protected function fileExistsWithinZip($zipStreamURI)
    {
        $doesFileExists = false;

        $pattern = '/zip:\/\/([^#]+)#(.*)/';
        if (preg_match($pattern, $zipStreamURI, $matches)) {
            $zipFilePath = $matches[1];
            $innerFilePath = $matches[2];

            $zip = new \ZipArchive();
            if ($zip->open($zipFilePath) === true) {
                $doesFileExists = ($zip->locateName($innerFilePath) !== false);
                $zip->close();
            }
        }

        return $doesFileExists;
    }
821887
public function extract(\ZipArchive $archive): void
    {
        $destination = $this->pluginDir;

        if (!is_writable($destination)) {
            throw new PluginExtractionException(sprintf('Destination directory "%s" is not writable', $destination));
        }

        $pluginName = $this->getPluginName($archive);
        $this->validatePluginZip($pluginName, $archive);

        $oldFile = $this->findOldFile($pluginName);
        $backupFile = $this->createBackupFile($oldFile);

        try {
            $archive->extractTo($destination);

            if ($backupFile !== '') {
                $this->filesystem->remove($backupFile);
            }

            unlink($archive->filename);
        } catch (\Exception $e) {
            if ($backupFile !== '') {
                $this->filesystem->rename($backupFile, $oldFile);
            }
            throw $e;
        }

        $this->clearOpcodeCache();
    }
770758
public function get_info($index) {
        if (!isset($this->za)) {
            return false;
        }

        // Need to use the ZipArchive's numfiles, as $this->count() relies on this function to count actual files (skipping OSX junk).
        if ($index < 0 or $index >=$this->za->numFiles) {
            return false;
        }

        // PHP 5.6 introduced encoding guessing logic, we need to fall back
        // to raw ZIP_FL_ENC_RAW (== 64) to get consistent results as in PHP 5.5.
        $result = $this->za->statIndex($index, 64);

        if ($result === false) {
            return false;
        }

        $info = new stdClass();
        $info->index             = $index;
        $info->original_pathname = $result['name'];
        $info->pathname          = $this->unmangle_pathname($result['name']);
        $info->mtime             = (int)$result['mtime'];

        if ($info->pathname[strlen($info->pathname)-1] === '/') {
            $info->is_directory = true;
            $info->size         = 0;
        } else {
            $info->is_directory = false;
            $info->size         = (int)$result['size'];
        }

        if ($this->is_system_file($info)) {
            // Don't return system files.
            return false;
        }

        return $info;
    }
1331978
public static function zip()
    {
        $args = func_get_args();
        $originalArr = $args[0];

        array_shift($args);

        $array = [];

        foreach ($originalArr as $key => $value) {
            $array[$key] = [$value];

            foreach ($args as $k => $v) {
                $array[$key][] = current($args[$k]);

                if (next($args[$k]) === false && $args[$k] !== [null]) {
                    $args[$k] = [null];
                }
            }
        }

        return $array;
    }
1342189
def _get_archive_name(self, archname=None):
        '''
        
        '''
        archname = re.sub('[^a-z0-9]', '', (archname or '').lower()) or 'support'
        for grain in ['fqdn', 'host', 'localhost', 'nodename']:
            host = __grains__.get(grain)
            if host:
                break
        if not host:
            host = 'localhost'

        return os.path.join(tempfile.gettempdir(),
                            '{hostname}-{archname}-{date}-{time}.bz2'.format(archname=archname,
                                                                             hostname=host,
                                                                             date=time.strftime('%Y%m%d'),
                                                                             time=time.strftime('%H%M%S')))
585320
private function listAllFiles($folder, $extension = '*')
    {
        /**
         * @var array<mixed, string> $fileList
         * @var string $i
         * @var string $file
         * @var \RecursiveDirectoryIterator $dir
         * @var \RecursiveIteratorIterator $ite
         */
        $dir = new \RecursiveDirectoryIterator($folder);
        $ite = new \RecursiveIteratorIterator($dir);
        if ($extension === '*') {
            $pattern = '/.*/';
        } else {
            $pattern = '/.*\.' . $extension . '$/';
        }
        $files = new \RegexIterator($ite, $pattern, \RegexIterator::GET_MATCH);

        /** @var array<string, string> $fileList */
        $fileList = [];

        /**
         * @var string $fileSub
         */
        foreach($files as $fileSub) {
            $fileList = \array_merge($fileList, $fileSub);
        }

        /**
         * @var string $i
         * @var string $file
         */
        foreach ($fileList as $i => $file) {
            if (\preg_match('#/\.{1,2}$#', (string) $file)) {
                unset($fileList[$i]);
            }
        }
        return \array_values($fileList);
    }
1291941
public function create($archive, $files)
	{
		$contents = array();
		$ctrldir = array();

		foreach ($files as $file)
		{
			$this->addToZIPFile($file, $contents, $ctrldir);
		}

		return $this->createZIPFile($contents, $ctrldir, $archive);
	}
1299910
public function webtreesZipContents(string $zip_file): Collection
    {
        $zip_adapter    = new ZipArchiveAdapter($zip_file, null, 'webtrees');
        $zip_filesystem = new Filesystem(new CachedAdapter($zip_adapter, new Memory()));
        $paths          = new Collection($zip_filesystem->listContents('', true));

        return $paths->filter(static function (array $path): bool {
            return $path['type'] === 'file';
        })
            ->map(static function (array $path): string {
                return $path['path'];
            });
    }
1171911
public function duplicate($p_archive)
    {
        $v_result = 1;

        // ----- Reset the error handler
        $this->privErrorReset();

        // ----- Look if the $p_archive is a PclZip object
        if ((is_object($p_archive)) && (get_class($p_archive) == 'pclzip')) {
            // ----- Duplicate the archive
            $v_result = $this->privDuplicate($p_archive->zipname);
        } elseif (is_string($p_archive)) {
            // ----- Look if the $p_archive is a string (so a filename)
            // ----- Check that $p_archive is a valid zip file
            // TBC : Should also check the archive format
            if (!is_file($p_archive)) {
                // ----- Error log
                PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "No file with filename '".$p_archive."'");
                $v_result = PCLZIP_ERR_MISSING_FILE;
            } else {
                // ----- Duplicate the archive
                $v_result = $this->privDuplicate($p_archive);
            }
        } else {
            // ----- Invalid variable
            // ----- Error log
            PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add");
            $v_result = PCLZIP_ERR_INVALID_PARAMETER;
        }

        // ----- Return
        return $v_result;
    }
841475
private static function expandFilenameBraces($pattern) {
    $result = [];
    if (preg_match(self::BRACE_PATTERN, $pattern, $matches) === 1) {
      $items = explode(",", $matches[2]);
      foreach($items as $match) {
        $str = $matches[1] . $match . $matches[3];
        $exp = static::expandFilenameBraces($str);
        $result = array_merge($result, $exp);
      }
    } else {
      $result[] = $pattern;
    }
    return $result;
  }
836884
static function treeCacheFilename( $key, $templateFilepath )
    {
        $internalCharset = eZTextCodec::internalCharset();
        $extraName = '';
        if ( preg_match( "#^.+/(.*)\.tpl$#", $templateFilepath, $matches ) )
            $extraName = '-' . $matches[1];
        else if ( preg_match( "#^(.*)\.tpl$#", $templateFilepath, $matches ) )
            $extraName = '-' . $matches[1];
        $cacheFileKey = "$key-$internalCharset";
        $cacheFileName = md5( $cacheFileKey ) . $extraName . '.php';
        return $cacheFileName;
    }
109051
public static File zip(List<String> fileNames, String zipPath, String encoding) {
    try {
      FileOutputStream f = new FileOutputStream(zipPath);
      ZipArchiveOutputStream zos = (ZipArchiveOutputStream) new ArchiveStreamFactory()
          .createArchiveOutputStream(ArchiveStreamFactory.ZIP, f);
      if (null != encoding) {
        zos.setEncoding(encoding);
      }
      for (int i = 0; i < fileNames.size(); i++) {
        String fileName = fileNames.get(i);
        String entryName = Strings.substringAfterLast(fileName, File.separator);
        ZipArchiveEntry entry = new ZipArchiveEntry(entryName);
        zos.putArchiveEntry(entry);
        FileInputStream fis = new FileInputStream(fileName);
        IOs.copy(fis, zos);
        fis.close();
        zos.closeArchiveEntry();
      }
      zos.close();
      return new File(zipPath);
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
1106277
protected function _get_zip_url( $remote ) {
		$url = false;

		if ( ! empty( $remote->assets ) && is_array( $remote->assets ) ) {
			if ( ! empty( $remote->assets[0] ) && is_object( $remote->assets[0] ) ) {
				if ( ! empty( $remote->assets[0]->browser_download_url ) ) {
					$url = $remote->assets[0]->browser_download_url;
				}
			}
		}

		$tag_name = isset( $remote->tag_name ) ? $remote->tag_name : null;

		if ( ! $url && $tag_name ) {
			$url = sprintf(
				'https://github.com/%1$s/%2$s/archive/%3$s.zip',
				$this->user_name,
				$this->repository,
				$tag_name
			);
		}

		return apply_filters(
			sprintf(
				'inc2734_github_theme_updater_zip_url_%1$s/%2$s',
				$this->user_name,
				$this->repository
			),
			$url,
			$this->user_name,
			$this->repository,
			$tag_name
		);
	}
583450
public function getArchiveLink(string $archiveFormat = AbstractApi::ARCHIVE_TARBALL,
                                   string $ref = AbstractApi::BRANCH_MASTER): array
    {
        return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/:archive_format/:ref',
            $this->getRepositories()->getOwner(), $this->getRepositories()->getRepo(), $archiveFormat, $ref));
    }
373745
def _list_archive_members(archive):
    

    if isinstance(archive, zipfile.ZipFile):
        return archive.infolist()
    return archive.getmembers()