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

From: Date: Sat, 16 Apr 2005 22:15:29 +0000
Subject: cvs: pear /File_Archive/Archive/Reader Tar.php /File_Archive/Archive/Writer Tar.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-31198@lists.php.net to get a copy of this message
vincentlascaux Sat Apr 16 18:15:29 2005 EDT Modified files: /pear/File_Archive/Archive/Reader Tar.php /pear/File_Archive/Archive/Writer Tar.php Log: Allow reading non USTAR tar files Split the filename after 100 chars so that non USTAR readers can understand the archives with files that have a name less than 100 chars long http://cvs.php.net/diff.php/pear/File_Archive/Archive/Reader/Tar.php?r1=1.9&r2=1.10&ty=u Index: pear/File_Archive/Archive/Reader/Tar.php diff -u pear/File_Archive/Archive/Reader/Tar.php:1.9 pear/File_Archive/Archive/Reader/Tar.php:1.10 --- pear/File_Archive/Archive/Reader/Tar.php:1.9 Thu Feb 24 08:30:57 2005 +++ pear/File_Archive/Archive/Reader/Tar.php Sat Apr 16 18:15:27 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.9 2005/02/24 13:30:57 vincentlascaux Exp $ + * @version CVS: $Id: Tar.php,v 1.10 2005/04/16 22:15:27 vincentlascaux Exp $ * @link http://pear.php.net/package/File_Archive */ @@ -117,7 +117,7 @@ $header = unpack( "a100filename/a8mode/a8uid/a8gid/a12size/a12mtime/". "a8checksum/a1type/a100linkname/a6magic/a2version/". - "a32uname/a32gname/a8devmajor/a8devminor/a155path", + "a32uname/a32gname/a8devmajor/a8devminor/a155prefix", $rawHeader); $this->currentStat = array( 2 => octdec($header['mode']), @@ -126,9 +126,15 @@ 7 => octdec($header['size']), 9 => octdec($header['mtime']) ); - $this->currentFilename = $this->getStandardURL( - $header['path'] . $header['filename'] - ); + 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) { http://cvs.php.net/diff.php/pear/File_Archive/Archive/Writer/Tar.php?r1=1.11&r2=1.12&ty=u Index: pear/File_Archive/Archive/Writer/Tar.php diff -u pear/File_Archive/Archive/Writer/Tar.php:1.11 pear/File_Archive/Archive/Writer/Tar.php:1.12 --- pear/File_Archive/Archive/Writer/Tar.php:1.11 Sat Apr 16 15:01:25 2005 +++ pear/File_Archive/Archive/Writer/Tar.php Sat Apr 16 18:15:28 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.11 2005/04/16 19:01:25 vincentlascaux Exp $ + * @version CVS: $Id: Tar.php,v 1.12 2005/04/16 22:15:28 vincentlascaux Exp $ * @link http://pear.php.net/package/File_Archive */ @@ -71,19 +71,14 @@ $type = 9; // Unknown } - $pos = strrpos($filename, "/"); - if ($pos !== FALSE) { - $path = substr($filename, 0, $pos+1); - $path = preg_replace("/^(\.{1,2}(\/|\\\))+/","",$path); - - $file = substr($filename, $pos+1); - } else { - $path = ""; - $file = $filename; + $filePrefix = ''; + if (strlen($filename) > 100) { + $filePrefix = substr($filename, 0, 100); + $filename = substr($filename, 100); } $blockbeg = pack("a100a8a8a8a12a12", - $file, + $filename, decoct($mode), sprintf("%6s ",decoct($uid)), sprintf("%6s ",decoct($gid)), @@ -100,7 +95,7 @@ "Unknown", "", "", - $path, + $filePrefix, ""); $checksum = 8*ord(" "); @@ -208,7 +203,7 @@ /** - * A tar archive cannot contain files with name of folders longer than 100 chars + * A tar archive cannot contain files with name of folders longer than 255 chars * This filter removes them * * @see File_Archive_Predicate, File_Archive_Reader_Filter @@ -218,8 +213,7 @@ { function isTrue($source) { - $pos = strrpos($source->getFilename(), "/"); - return ($pos<100) && (strlen($filename) - $pos < 155); + return strlen($source->getFilename()) <= 255; } }

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