Ok, I checked http://pear.php.net/package/Archive_Zip as posted by Irmantas,
but it says this :
"This package is not maintained anymore and has been superseded. Package has moved to channel pecl.php.net, package zip."
Then I searched pear.php.net and stumbled upon :
http://pear.php.net/package/File_Archive
File_Archive doesn't have a very intuitive set of methods though.
But I wanted simple functionality of making a tar file, and
extracting files from a tar file.
Following snippets achieve that :
Extracting files from a tar file ->
<?php
require_once "File/Archive.php";
$tmp = 'output';
$t1 = 'check.tar';
File_Archive::setOption('tmpDirectory','tmp');
$r = File_Archive::extract(
File_Archive::read($t1.'/'),
File_Archive::toFiles($tmp)
);
?>
Tar dosyası dosya ekleme ->
<?php
require_once "Archive.php";
$dir = "../../mysql/data/blackStone/";
$files[0] = "";
$i = 0;
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false ) {
if( $file != "." && $file != ".." )
$files[$i++] = $dir.$file;
}
}
File_Archive::extract(
$files,
File_Archive::toArchive(
'check.tar',
File_Archive::toOutput()
)
);
?>