summaryrefslogtreecommitdiff
path: root/pear/Archive
diff options
context:
space:
mode:
authorStig Bakken <ssb@php.net>2002-05-27 19:28:09 +0000
committerStig Bakken <ssb@php.net>2002-05-27 19:28:09 +0000
commit3337c2d307d738b66cf549941d253bc2aa523ae2 (patch)
treeacdae2cb8723498745bb944d9d74933e65751a79 /pear/Archive
parent65b11e4aae3e8a6fae69148e69cf4f87f5f80d47 (diff)
downloadphp-git-3337c2d307d738b66cf549941d253bc2aa523ae2.tar.gz
* better gzip detection (magic cookie)
Diffstat (limited to 'pear/Archive')
-rw-r--r--pear/Archive/Tar.php18
1 files changed, 15 insertions, 3 deletions
diff --git a/pear/Archive/Tar.php b/pear/Archive/Tar.php
index 86bf0ee07a..3796ae2451 100644
--- a/pear/Archive/Tar.php
+++ b/pear/Archive/Tar.php
@@ -65,8 +65,20 @@ class Archive_Tar extends PEAR
{
$this->PEAR();
if ($p_compress === null) {
- if (substr($p_tarname, -4) == '.tar') {
- $p_compress = false;
+ if (@file_exists($p_tarname)) {
+ if ($fp = @fopen($p_tarname, "r")) {
+ // look for gzip magic cookie
+ $data = fread($fp, 2);
+ if ($data == "\37\213") {
+ $p_compress = true;
+ }
+ }
+ } else {
+ // probably a remote file or some file accessible
+ // through a stream interface
+ if (substr($p_tarname, -2) == 'gz') {
+ $p_compress = true;
+ }
}
}
$this->_tarname = $p_tarname;
@@ -86,7 +98,7 @@ class Archive_Tar extends PEAR
return false;
}
}
- $this->_compress = $p_compress;
+ $this->_compress = (bool)$p_compress;
}
// }}}