<?php defined('SYSPATH') or die('No direct script access.');
/**
 * Archive library bzip driver.
 *
 * $Id: bzip.php - 2008-06-22 19:57:23Z Caio Ariede $
 *
 * @package    Archive
 * @author     Kohana Team
 * @copyright  (c) 2007-2008 Kohana Team
 * @license    http://kohanaphp.com/license.html
 */
class Archive_Bzip_Driver implements Archive_Driver {

    public function 
create($paths$filename FALSE)
    {

        
$archive = new Archive('tar');

        foreach (
$paths as $set)
        {
            
$archive->add($set[0], $set[1]);
        }

        
$gzfile bzcompress($archive->create());

        if (
$filename == FALSE)
        {
            return 
$gzfile;
        }

        if (
substr($filename, -8) != '.tar.bz2')
        {
            
// Append tar extension
            
$filename .= '.tar.bz2';
        }

        
// Create the file in binary write mode
        
$file fopen($filename'wb');

        
// Lock the file
        
flock($fileLOCK_EX);

        
// Write the tar file
        
$return fwrite($file$gzfile);

        
// Unlock the file
        
flock($fileLOCK_UN);

        
// Close the file
        
fclose($file);

        return (bool) 
$return;
    }

    public function 
add_data($file$name$contents NULL)
    {
    }

// End Archive_Bzip_Driver Class