class CRM_Utils_Zip

Utilities for working with zip files

Methods

static mixed
findBaseDirName( $zip)

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

static array(string)
findBaseDirs( $zip)

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

static string|bool
guessBasedir( $zip, $expected)

Determine the name of the folder within a zip.

static bool
createTestZip(string $zipName, array $dirs, array $files)

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

Details

at line 47
static mixed findBaseDirName( $zip)

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

Parameters

$zip

Return Value

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

at line 80
static array(string) findBaseDirs( $zip)

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

Parameters

$zip

Return Value

array(string) no trailing /

at line 104
static string|bool guessBasedir( $zip, $expected)

Determine the name of the folder within a zip.

Parameters

$zip
$expected

Return Value

string|bool Return string or FALSE

at line 134
static bool createTestZip(string $zipName, array $dirs, array $files)

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

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

Parameters

string $zipName file name.
array $dirs Array, list of directory paths.
array $files Array, keys are file names and values are file contents.

Return Value

bool