Skip to content

Commit

Permalink
implemented infoFromTgzFile()
Browse files Browse the repository at this point in the history
  • Loading branch information
tvvcox committed Sep 28, 2001
1 parent cb9991d commit 15ac056
Showing 1 changed file with 27 additions and 4 deletions.
31 changes: 27 additions & 4 deletions pear/PEAR/Common.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
// $Id$

require_once 'PEAR.php';
require_once 'Archive/Tar.php';

/**
* TODO:
Expand Down Expand Up @@ -372,10 +373,32 @@ function infoFromDescriptionFile($descfile)
*/
function infoFromTgzFile($file)
{
// untar in temp
// chdir($tmp);
//return $this->infoFromDescriptionFile('package.xml');
// clean temp
$file = basename($file); // XXX Fixme: Only allows file in the current dir
if (!@is_file($file)) {
return $this->raiseError('no tar file supplied');
}
$tar = new Archive_Tar($file, true);
// XXX Fixme Windows
$tmpdir = '/tmp' . DIRECTORY_SEPARATOR . $file;
if (file_exists($tmpdir)) {
return $this->raiseError('Tmpdir: ' . $tmpdir .' already exists',
null, PEAR_ERROR_TRIGGER, E_USER_ERROR);
}
if (!mkdir($tmpdir, 0755)) {
return $this->raiseError("Unable to create temporary directory $tmpdir.",
null, PEAR_ERROR_TRIGGER, E_USER_ERROR);
}
$tar->extract($tmpdir);
// Assume the decompressed dir name
if (($pos = strrpos($file, '.')) === false) {
return $this->raiseError('file doesn\'t follow the package name convention');
}
$pkgdir = substr($file, 0, $pos);

$xml = $tmpdir . DIRECTORY_SEPARATOR . $pkgdir . DIRECTORY_SEPARATOR .'package.xml';
$info = $this->infoFromDescriptionFile($xml);
system("rm -rf $tmpdir"); // XXX FIXME Windows
return $info;
}
}
?>

0 comments on commit 15ac056

Please sign in to comment.