cvs: pear /File_Archive/Archive/Reader Tar.php

From: Date: Sun, 17 Apr 2005 09:19:21 +0000
Subject: cvs: pear /File_Archive/Archive/Reader Tar.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-31220@lists.php.net to get a copy of this message
vincentlascaux Sun Apr 17 05:19:21 2005 EDT Modified files: /pear/File_Archive/Archive/Reader Tar.php Log: Discard folders, symbolic links... from the tar files that contain some http://cvs.php.net/diff.php/pear/File_Archive/Archive/Reader/Tar.php?r1=1.10&r2=1.11&ty=u Index: pear/File_Archive/Archive/Reader/Tar.php diff -u pear/File_Archive/Archive/Reader/Tar.php:1.10 pear/File_Archive/Archive/Reader/Tar.php:1.11 --- pear/File_Archive/Archive/Reader/Tar.php:1.10 Sat Apr 16 18:15:27 2005 +++ pear/File_Archive/Archive/Reader/Tar.php Sun Apr 17 05:19:21 2005 @@ -25,7 +25,7 @@ * @author Vincent Lascaux <vincentlascaux@php.net> * @copyright 1997-2005 The PHP Group * @license http://www.gnu.org/copyleft/lesser.html LGPL - * @version CVS: $Id: Tar.php,v 1.10 2005/04/16 22:15:27 vincentlascaux Exp $ + * @version CVS: $Id: Tar.php,v 1.11 2005/04/17 09:19:21 vincentlascaux Exp $ * @link http://pear.php.net/package/File_Archive */ @@ -102,58 +102,61 @@ return $error; } - $error = $this->source->skip($this->leftLength + $this->footerLength); - if (PEAR::isError($error)) { - return $error; - } - $rawHeader = $this->source->getData(512); - if (PEAR::isError($rawHeader)) { - return $rawHeader; - } - if (strlen($rawHeader)<512 || $rawHeader == pack("a512", "")) { - return false; - } - - $header = unpack( - "a100filename/a8mode/a8uid/a8gid/a12size/a12mtime/". - "a8checksum/a1type/a100linkname/a6magic/a2version/". - "a32uname/a32gname/a8devmajor/a8devminor/a155prefix", - $rawHeader); - $this->currentStat = array( - 2 => octdec($header['mode']), - 4 => octdec($header['uid']), - 5 => octdec($header['gid']), - 7 => octdec($header['size']), - 9 => octdec($header['mtime']) - ); - if ($header['magic'] == 'ustar') { - $this->currentFilename = $this->getStandardURL( - $header['prefix'] . $header['filename'] - ); - } else { - $this->currentFilename = $this->getStandardURL( - $header['filename'] - ); - } - - $this->leftLength = $this->currentStat[7]; - if ($this->leftLength % 512 == 0) { - $this->footerLength = 0; - } else { - $this->footerLength = 512 - $this->leftLength%512; - } - - $checksum = 8*ord(" "); - for ($i = 0; $i < 148; $i++) { - $checksum += ord($rawHeader{$i}); - } - for ($i = 156; $i < 512; $i++) { - $checksum += ord($rawHeader{$i}); - } - - if (octdec($header['checksum']) != $checksum) { - die('Checksum error on entry '.$this->currentFilename); - } + do + { + $error = $this->source->skip($this->leftLength + $this->footerLength); + if (PEAR::isError($error)) { + return $error; + } + $rawHeader = $this->source->getData(512); + if (PEAR::isError($rawHeader)) { + return $rawHeader; + } + if (strlen($rawHeader)<512 || $rawHeader == pack("a512", "")) { + return false; + } + + $header = unpack( + "a100filename/a8mode/a8uid/a8gid/a12size/a12mtime/". + "a8checksum/a1type/a100linkname/a6magic/a2version/". + "a32uname/a32gname/a8devmajor/a8devminor/a155prefix", + $rawHeader); + $this->currentStat = array( + 2 => octdec($header['mode']), + 4 => octdec($header['uid']), + 5 => octdec($header['gid']), + 7 => octdec($header['size']), + 9 => octdec($header['mtime']) + ); + if ($header['magic'] == 'ustar') { + $this->currentFilename = $this->getStandardURL( + $header['prefix'] . $header['filename'] + ); + } else { + $this->currentFilename = $this->getStandardURL( + $header['filename'] + ); + } + + $this->leftLength = $this->currentStat[7]; + if ($this->leftLength % 512 == 0) { + $this->footerLength = 0; + } else { + $this->footerLength = 512 - $this->leftLength%512; + } + + $checksum = 8*ord(" "); + for ($i = 0; $i < 148; $i++) { + $checksum += ord($rawHeader{$i}); + } + for ($i = 156; $i < 512; $i++) { + $checksum += ord($rawHeader{$i}); + } + + if (octdec($header['checksum']) != $checksum) { + die('Checksum error on entry '.$this->currentFilename); + } + } while ($header['type'] != 0); return true; }

« previous php.pear.cvs (#31220) next »