Fw: [PEAR-CVS] cvs: pear /Archive_Tar Tar.php
| From: | Vincent Blavet | Date: | Sun, 04 Nov 2001 22:29:07 +0000 |
| Subject: | Fw: [PEAR-CVS] cvs: pear /Archive_Tar Tar.php | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-2539@lists.php.net to get a copy of this message | ||
Martin, Pear-dev,
A commit a bug correction, that should remove the problem of storing a not
null "file" size for a folder item. The bug does not seems to come from a
missing clearstatcache() statement, but more on a call to filesize() when
the file is in fact a folder.
Question : what should normally answer filesize() when the file is a folder
? 0 or anything else ?
Martin can you re-do the "pear package" and see if my correction resolve the
bug in your case ?
Thanks,
Vincent
----- Original Message -----
From: "Vincent Blavet" <vincent@blavet.net>
To: <pear-cvs@lists.php.net>
Sent: Sunday, November 04, 2001 11:21 PM
Subject: [PEAR-CVS] cvs: pear /Archive_Tar Tar.php
> vblavet Sun Nov 4 17:21:37 2001 EDT
>
> Modified files:
> /pear/Archive_Tar Tar.php
> Log:
> * Correct invalid (not null) size while archiving a folder
> * Improve extract of a folder while stored size is invalid not null size
> * Add missing clearstatcache()
>
> Index: pear/Archive_Tar/Tar.php
> diff -u pear/Archive_Tar/Tar.php:1.9 pear/Archive_Tar/Tar.php:1.10
> --- pear/Archive_Tar/Tar.php:1.9 Sun Oct 28 06:24:11 2001
> +++ pear/Archive_Tar/Tar.php Sun Nov 4 17:21:36 2001
> @@ -16,7 +16,7 @@
> // | Authors: Vincent Blavet <vincent@blavet.net>
|
> //
+----------------------------------------------------------------------+
> //
> -// $Id: Tar.php,v 1.9 2001/10/28 11:24:11 mfischer Exp $
> +// $Id: Tar.php,v 1.10 2001/11/04 22:21:36 vblavet Exp $
>
> require_once 'PEAR.php';
>
> @@ -24,7 +24,7 @@
> * Creates a (compressed) Tar archive
> *
> * @author Vincent Blavet <vincent@blavet.net>
> -* @version $Revision: 1.9 $
> +* @version $Revision: 1.10 $
> * @package Archive
> */
> class Archive_Tar extends PEAR
> @@ -601,15 +601,16 @@
> $v_gid = sprintf("%6s ", DecOct($v_info[5]));
> $v_perms = sprintf("%6s ", DecOct(fileperms($p_filename)));
>
> - clearstatcache();
> - $v_size = sprintf("%11s ", DecOct(filesize($p_filename)));
> -
> $v_mtime = sprintf("%11s", DecOct(filemtime($p_filename)));
>
> - if (@is_dir($p_filename))
> + if (@is_dir($p_filename)) {
> $v_typeflag = "5";
> - else
> + $v_size = sprintf("%11s ", DecOct(0));
> + } else {
> $v_typeflag = "";
> + clearstatcache();
> + $v_size = sprintf("%11s ", DecOct(filesize($p_filename)));
> + }
>
> $v_linkname = "";
>
> @@ -714,7 +715,9 @@
> $v_header[gid] = OctDec(trim($v_data[gid]));
> $v_header[size] = OctDec(trim($v_data[size]));
> $v_header[mtime] = OctDec(trim($v_data[mtime]));
> - $v_header[typeflag] = $v_data[typeflag];
> + if (($v_header[typeflag] = $v_data[typeflag]) == "5") {
> + $v_header[size] = 0;
> + }
> /* ----- All these fields are removed form the header because
they do not carry interesting info
> $v_header[link] = trim($v_data[link]);
> $v_header[magic] = trim($v_data[magic]);
> @@ -735,7 +738,7 @@
> $v_result=true;
> $v_nb = 0;
> $v_extract_all = true;
> - $v_listing = false;
> + $v_listing = false;
>
> if ($p_path == "" || (substr($p_path, 0, 1) != "/" &&
> substr($p_path,
0, 3) != "../" && substr($p_path, 1, 3) != ":\\")) {
> $p_path = "./".$p_path;
> @@ -808,7 +811,7 @@
>
> // ----- Look if this file need to be extracted
> if (($v_extract_file) && (!$v_listing))
> - {
> + {
> if (($p_remove_path != "")
> && (substr($v_header[filename], 0, $p_remove_path_size) ==
$p_remove_path))
> $v_header[filename] = substr($v_header[filename],
$p_remove_path_size);
> @@ -883,6 +886,7 @@
> }
>
> // ----- Check the file size
> + clearstatcache();
> if (filesize($v_header[filename]) != $v_header[size]) {
> $this->_error("Extracted file $v_header[filename] does not
have the correct file size '".filesize($v_filename)."' ($v_header[size]
expected). Archive may be corrupted.");
> return false;
> @@ -974,6 +978,7 @@
> if (!$this->_openReadWrite())
> return false;
>
> + clearstatcache();
> $v_size = filesize($this->_tarname);
> fseek($this->_file, $v_size-512);
>
> @@ -1042,4 +1047,4 @@
> // }}}
>
> }
> -?>
> +?>
> \ No newline at end of file
>
>
>
> --
> PEAR CVS Mailing List (http://pear.php.net/)
> To unsubscribe, e-mail: pear-cvs-unsubscribe@lists.php.net
> For additional commands, e-mail: pear-cvs-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
>