Documentation

CRM_Utils_Zip
in package

Utilities for working with zip files

Table of Contents

Methods

createTestZip()  : bool
An inefficient helper for creating a ZIP file from data in memory.
findBaseDirName()  : mixed
Given a zip file which contains a single root directory, determine the root's name.
findBaseDirs()  : mixed
Given a zip file, find all directory names in the root
guessBasedir()  : string|bool
Determine the name of the folder within a zip.

Methods

createTestZip()

An inefficient helper for creating a ZIP file from data in memory.

public static createTestZip(string $zipName, array<string|int, mixed> $dirs, array<string|int, mixed> $files) : bool

This is only intended for building temp files for unit-testing.

Parameters
$zipName : string

file name.

$dirs : array<string|int, mixed>

Array, list of directory paths.

$files : array<string|int, mixed>

Array, keys are file names and values are file contents.

Return values
bool

findBaseDirName()

Given a zip file which contains a single root directory, determine the root's name.

public static findBaseDirName(ZipArchive $zip) : mixed
Parameters
$zip : ZipArchive
Return values
mixed

FALSE if #root level items !=1; otherwise, the name of base dir

findBaseDirs()

Given a zip file, find all directory names in the root

public static findBaseDirs(ZipArchive $zip) : mixed
Parameters
$zip : ZipArchive
Tags
@return

array(string) no trailing /

guessBasedir()

Determine the name of the folder within a zip.

public static guessBasedir(ZipArchive $zip, string $expected) : string|bool
Parameters
$zip : ZipArchive
$expected : string
Return values
string|bool

Return string or FALSE


        
On this page

Search results