public function directory($source, $destination, $wrapper = '')
    {
        $files = gplcart_file_scan_recursive($source);

        if (empty($files)) {
            return false;
        }

        $this->set($destination, true);

        $added = 0;
        foreach ($files as $file) {

            if (is_dir($file)) {
                $added++;
                continue;
            }

            $prefix = $wrapper === '' ? '' : $wrapper . DIRECTORY_SEPARATOR;
            $relative = $prefix . substr($file, strlen($source) + 1);
            $added += (int) $this->zip->addFile($file, $relative);
        }

        $result = count($files) == $added;
        $this->zip->close();
        return $result;
    }
public function directory($source, $destination, $wrapper = '')
    {
        $files = gplcart_file_scan_recursive($source);

        if (empty($files)) {
            return false;
        }

        $this->set($destination, true);

        $added = 0;
        foreach ($files as $file) {

            if (is_dir($file)) {
                $added++;
                continue;
            }

            $prefix = $wrapper === '' ? '' : $wrapper . DIRECTORY_SEPARATOR;
            $relative = $prefix . substr($file, strlen($source) + 1);
            $added += (int) $this->zip->addFile($file, $relative);
        }

        $result = count($files) == $added;
        $this->zip->close();
        return $result;
    }
public function directory ( $ source , $ destination , $ wrapper = '' ) { $ files = gplcart_file_scan_recursive ( $ source ) ; if ( empty ( $ files ) ) { return false ; } $ this -> set ( $ destination , true ) ; $ added = 0 ; foreach ( $ files as $ file ) { if ( is_dir ( $ file ) ) { $ added ++ ; continue ; } $ prefix = $ wrapper === '' ? '' : $ wrapper . DIRECTORY_SEPARATOR ; $ relative = $ prefix . substr ( $ file , strlen ( $ source ) + 1 ) ; $ added += ( int ) $ this -> zip -> addFile ( $ file , $ relative ) ; } $ result = count ( $ files ) == $ added ; $ this -> zip -> close ( ) ; return $ result ; }
Zip a whole folder
@param string $source
@param string $destination
@param string $wrapper Wrapping local directory in the archive
@return boolean
Zip a whole folder