Back to index

php5  5.3.10
Public Member Functions | Protected Attributes
zipmaker Class Reference

List of all members.

Public Member Functions

 __construct ($path)
 addFile ($path, $fileOrStream)
 save a file inside this package
 init ()
 Initialize the package creator.
 mkdir ($dir)
 Create an internal directory, creating parent directories as needed.
 close ()
 Finish saving the package.

Protected Attributes

 $archive
 $zip
 $path

Detailed Description

Definition at line 3 of file zipmaker.php.inc.


Constructor & Destructor Documentation

zipmaker::__construct ( path)

Definition at line 16 of file zipmaker.php.inc.

    {
        if (!class_exists('ZIPArchive')) {
            throw new Exception(
                'Zip extension is not available');
        }
        $this->path = $path;
    }

Member Function Documentation

zipmaker::addFile ( path,
fileOrStream 
)

save a file inside this package

Parameters:
stringrelative path within the package
string|resourcefile contents or open file handle

Definition at line 30 of file zipmaker.php.inc.

    {
        if (is_resource($fileOrStream)) {
            $this->zip->addFromString($path, stream_get_contents($fileOrStream));
        } else {
            $this->zip->addFromString($path, $fileOrStream);
        }
    }

Finish saving the package.

Definition at line 66 of file zipmaker.php.inc.

    {
        $this->zip->close();
    }

Initialize the package creator.

Definition at line 42 of file zipmaker.php.inc.

    {
        $this->zip = new ZipArchive;
        if (true !== $this->zip->open($this->path, ZIPARCHIVE::CREATE)) {
            throw new Exception(
                'Cannot open ZIP archive ' . $this->path
            );
        }
    }
zipmaker::mkdir ( dir)

Create an internal directory, creating parent directories as needed.

This is a no-op for the tar creator

Parameters:
string$dir

Definition at line 58 of file zipmaker.php.inc.

    {
        $this->zip->addEmptyDir($dir);
    }

Member Data Documentation

zipmaker::$archive [protected]

Definition at line 10 of file zipmaker.php.inc.

zipmaker::$path [protected]

Definition at line 15 of file zipmaker.php.inc.

zipmaker::$zip [protected]

Definition at line 14 of file zipmaker.php.inc.


The documentation for this class was generated from the following file: