src/xPDO/Compression/xPDOZip.php
public function pack($source, array $options = array()) {
        $results = array();
        if ($this->_archive) {
            $target = $this->getOption(xPDOZip::ZIP_TARGET, $options, '');
            if (is_dir($source)) {
                if ($dh = opendir($source)) {
                    if ($source[strlen($source) - 1] !== '/') $source .= '/';
                    $targetDir = rtrim($target, '/');
                    if (!empty($targetDir)) {
                        if ($this->_archive->addEmptyDir($targetDir)) {
                            $results[$target] = "Successfully added directory {$target} from {$source}";
                        } else {
                            $results[$target] = "Error adding directory {$target} from {$source}";
                            $this->_errors[] = $results[$target];
                        }
                    }
                    while (($file = readdir($dh)) !== false) {
                        if (is_dir($source . $file)) {
                            if (($file !== '.') && ($file !== '..')) {
                                $results = $results + $this->pack($source . $file . '/', array_merge($options, array(xPDOZip::ZIP_TARGET => $target . $file . '/')));
                            }
                        } elseif (is_file($source . $file)) {
                            if ($this->_archive->addFile($source . $file, $target . $file)) {
                                $results[$target . $file] = "Successfully packed {$target}{$file} from {$source}{$file}";
                            } else {
                                $results[$target . $file] = "Error packing {$target}{$file} from {$source}{$file}";
                                $this->_errors[] = $results[$target . $file];
                            }
                        } else {
                            $results[$target . $file] = "Error packing {$target}{$file} from {$source}{$file}";
                            $this->_errors[] = $results[$target . $file];
                        }
                    }
                }
            } elseif (is_file($source)) {
                $file = basename($source);
                if ($this->_archive->addFile($source, $target . $file)) {
                    $results[$target . $file] = "Successfully packed {$target}{$file} from {$source}";
                } else {
                    $results[$target . $file] = "Error packing {$target}{$file} from {$source}";
                    $this->_errors[] = $results[$target . $file];
                }
            } else {
                $this->_errors[]= "Invalid source specified: {$source}";
            }
        }
        return $results;
    }
public function pack($source, array $options = array()) {
        $results = array();
        if ($this->_archive) {
            $target = $this->getOption(xPDOZip::ZIP_TARGET, $options, '');
            if (is_dir($source)) {
                if ($dh = opendir($source)) {
                    if ($source[strlen($source) - 1] !== '/') $source .= '/';
                    $targetDir = rtrim($target, '/');
                    if (!empty($targetDir)) {
                        if ($this->_archive->addEmptyDir($targetDir)) {
                            $results[$target] = "Successfully added directory {$target} from {$source}";
                        } else {
                            $results[$target] = "Error adding directory {$target} from {$source}";
                            $this->_errors[] = $results[$target];
                        }
                    }
                    while (($file = readdir($dh)) !== false) {
                        if (is_dir($source . $file)) {
                            if (($file !== '.') && ($file !== '..')) {
                                $results = $results + $this->pack($source . $file . '/', array_merge($options, array(xPDOZip::ZIP_TARGET => $target . $file . '/')));
                            }
                        } elseif (is_file($source . $file)) {
                            if ($this->_archive->addFile($source . $file, $target . $file)) {
                                $results[$target . $file] = "Successfully packed {$target}{$file} from {$source}{$file}";
                            } else {
                                $results[$target . $file] = "Error packing {$target}{$file} from {$source}{$file}";
                                $this->_errors[] = $results[$target . $file];
                            }
                        } else {
                            $results[$target . $file] = "Error packing {$target}{$file} from {$source}{$file}";
                            $this->_errors[] = $results[$target . $file];
                        }
                    }
                }
            } elseif (is_file($source)) {
                $file = basename($source);
                if ($this->_archive->addFile($source, $target . $file)) {
                    $results[$target . $file] = "Successfully packed {$target}{$file} from {$source}";
                } else {
                    $results[$target . $file] = "Error packing {$target}{$file} from {$source}";
                    $this->_errors[] = $results[$target . $file];
                }
            } else {
                $this->_errors[]= "Invalid source specified: {$source}";
            }
        }
        return $results;
    }
public function pack ( $ source , array $ options = array ( ) ) { $ results = array ( ) ; if ( $ this -> _archive ) { $ target = $ this -> getOption ( xPDOZip :: ZIP_TARGET , $ options , '' ) ; if ( is_dir ( $ source ) ) { if ( $ dh = opendir ( $ source ) ) { if ( $ source [ strlen ( $ source ) - 1 ] !== '/' ) $ source .= '/' ; $ targetDir = rtrim ( $ target , '/' ) ; if ( ! empty ( $ targetDir ) ) { if ( $ this -> _archive -> addEmptyDir ( $ targetDir ) ) { $ results [ $ target ] = "Successfully added directory {$target} from {$source}" ; } else { $ results [ $ target ] = "Error adding directory {$target} from {$source}" ; $ this -> _errors [ ] = $ results [ $ target ] ; } } while ( ( $ file = readdir ( $ dh ) ) !== false ) { if ( is_dir ( $ source . $ file ) ) { if ( ( $ file !== '.' ) && ( $ file !== '..' ) ) { $ results = $ results + $ this -> pack ( $ source . $ file . '/' , array_merge ( $ options , array ( xPDOZip :: ZIP_TARGET => $ target . $ file . '/' ) ) ) ; } } elseif ( is_file ( $ source . $ file ) ) { if ( $ this -> _archive -> addFile ( $ source . $ file , $ target . $ file ) ) { $ results [ $ target . $ file ] = "Successfully packed {$target}{$file} from {$source}{$file}" ; } else { $ results [ $ target . $ file ] = "Error packing {$target}{$file} from {$source}{$file}" ; $ this -> _errors [ ] = $ results [ $ target . $ file ] ; } } else { $ results [ $ target . $ file ] = "Error packing {$target}{$file} from {$source}{$file}" ; $ this -> _errors [ ] = $ results [ $ target . $ file ] ; } } } } elseif ( is_file ( $ source ) ) { $ file = basename ( $ source ) ; if ( $ this -> _archive -> addFile ( $ source , $ target . $ file ) ) { $ results [ $ target . $ file ] = "Successfully packed {$target}{$file} from {$source}" ; } else { $ results [ $ target . $ file ] = "Error packing {$target}{$file} from {$source}" ; $ this -> _errors [ ] = $ results [ $ target . $ file ] ; } } else { $ this -> _errors [ ] = "Invalid source specified: {$source}" ; } } return $ results ; }
Pack the contents from the source into the archive.

@todo Implement custom file filtering options

@param string $source The path to the source file(s) to pack.
@param array $options An array of options for the operation.
@return array An array of results for the operation.
Pack the contents from the source into the archive .