Login   Register  
PHP Classes
elePHPant
Icontem

There is no extraction possible o_O

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us

      TAR File Manager  >  All threads  >  There is no extraction possible o_O  >  (Un) Subscribe thread alerts  
Subject:There is no extraction possible o_O
Summary:Package rating comment
Messages:4
Author:David
Date:2008-01-13 19:14:49
Update:2010-09-14 08:22:30
 

David rated this package as follows:

Utility: Bad
Consistency: Bad

  1. There is no extraction possible o_O   Reply  
Picture of David
David
2008-01-13 19:14:49
There is no extraction possible o_O

  2. Re: There is no extraction possible o_O   Reply  
Picture of Bill Trikojus
Bill Trikojus
2009-05-04 13:16:16 - In reply to message 1 from David
really wish I read this comment before wasting a couple of hours on this class.

I wonder why it would say it could extract files in the class description...

  3. Re: There is no extraction possible o_O   Reply  
Picture of KsouL
KsouL
2010-03-22 14:33:14 - In reply to message 2 from Bill Trikojus
i have made an update to extract files from the archive, here is the code to had in the class :

function extractTar($path) {

if($this->numDirectories > 0) {
foreach($this->directories as $id => $information) {

$outputDir= $path.'/'.$information['name'] ;

if (!is_dir($outputDir)){
$res=mkdir($outputDir,$information['mode'],true);
// Cannot create output directory
if(!$res) {
return false ;
}
}
}
}
if($this->numFiles > 0) {
foreach($this->files as $id => $information) {
$fh = fopen($path.'/'.$information[name], 'w', false);
fwrite($fh,$information[file]);
fclose($fh);
}
}
else {
return false ;
}

return true ;
}

  4. Re: There is no extraction possible o_O   Reply  
Picture of Fèlix Casanellas
Fèlix Casanellas
2010-09-14 08:22:30 - In reply to message 3 from KsouL
Another extract function:


function extractTar($path) {



$last_path = '';



if($this->numFiles > 0) {

foreach($this->files as $id => $information) {

//Get the path and compare with the last

$file_path = substr($information[name], 0, - strlen(strrchr($information[name], "/")));



if($path.'/'.$file_path != $last_path){

//The file is in a diferent folder than the last

//Check if all the folders of the path exists, else create them

$folders = explode('/', $information[name]);

$folder_path = $path;



for($i=0; $i<count($folders)-1; $i++){

$folder_path .= '/'.$folders[$i];

if((file_exists($folder_path)) != '1') mkdir($folder_path);

}

$last_path = $folder_path;

}



$fh = fopen($path.'/'.$information[name], 'w', false);

fwrite($fh,$information[file]);

}

}

return true;

}