[eluser]Skuja[/eluser]
Actually i had to figure out 2 problems.
First was mentioned above. Second is that i need to compress only those files and folders inside $this->data_path not the whole path.
I extended Zip library and with a dirty hack made some changes to it:
Code:
<?php
class MY_Zip extends CI_Zip {
var $root_path;
var $zip_start_path;
function My_Zip()
{
parent::CI_Zip();
}
function read_dir_contents($path,$zip_root_path="") {
$this->root_path = str_replace("\\", "/", $path);
$this->zip_start_path = str_replace("\\", "/", $zip_root_path);
$this->read_dir($path);
}
function my_read_dir($path)
{
if ($fp = @opendir($path))
{
while (FALSE !== ($file = readdir($fp)))
{
if (@is_dir($path.$file) && substr($file, 0, 1) != '.')
{
$this->my_read_dir($path.$file."/");
}
elseif (substr($file, 0, 1) != ".")
{
if (FALSE !== ($data = file_get_contents($path.$file)))
{
$only_dir_conent_path = str_replace($this->root_path, "", $path);
$only_dir_conent_path = $this->zip_start_path.str_replace("\\", "/", $only_dir_conent_path);
$this->add_data($only_dir_conent_path.$file, $data);
}
}
}
return TRUE;
}
}
}
?>
One weird thing is that it compresses only those folders which contains files. Why?
And now i need to solve a new problem: How to delete zip folder after download() method is called - i believe it cant be done because of exit() in force_download() helper function. Any Ideas/Suggestions?