2
// stolen from PEAR2_Pyrus_Developer_Creator_Zip by Greg Beaver, the original author, for use in unit tests
16
function __construct($path)
18
if (!class_exists('ZIPArchive')) {
20
'Zip extension is not available');
26
* save a file inside this package
27
* @param string relative path within the package
28
* @param string|resource file contents or open file handle
30
function addFile($path, $fileOrStream)
32
if (is_resource($fileOrStream)) {
33
$this->zip->addFromString($path, stream_get_contents($fileOrStream));
35
$this->zip->addFromString($path, $fileOrStream);
40
* Initialize the package creator
44
$this->zip = new ZipArchive;
45
if (true !== $this->zip->open($this->path, ZIPARCHIVE::CREATE)) {
47
'Cannot open ZIP archive ' . $this->path
53
* Create an internal directory, creating parent directories as needed
55
* This is a no-op for the tar creator
60
$this->zip->addEmptyDir($dir);
64
* Finish saving the package
b'\\ No newline at end of file'