note 73724 added to function.gzread
| From: | zaotong at yahoo dot com | Date: | Wed, 07 Mar 2007 23:06:43 +0000 |
| Subject: | note 73724 added to function.gzread | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-124213@lists.php.net to get a copy of this message | ||
As was shown to me in another forum there is a way to get the uncompressed size of the gz file by
viewing the last 4 bytes of the gz file.
Here is a piece of code that will do this
<?php
$FileRead = 'SomeText.txt';
$FileOpen = fopen($FileRead, "rb");
fseek($FileOpen, -4, SEEK_END);
$buf = fread($FileOpen, 4);
$GZFileSize = end(unpack("V", $buf));
fclose($FileOpen);
$HandleRead = gzopen($FileRead, "rb");
$ContentRead = gzread($HandleRead, $GZFileSize);
?>
This will read the last 4 bytes of the gz file and use it as the file int for the gzread.
Thanks to stereofrog for helping me with this code.
----
Server IP: 216.194.113.175
Probable Submitter: 71.216.156.177
----
Manual Page -- http://www.php.net/manual/en/function.gzread.php
Edit -- https://master.php.net/note/edit/73724
Del: integrated -- https://master.php.net/note/delete/73724/integrated
Del: useless -- https://master.php.net/note/delete/73724/useless
Del: bad code -- https://master.php.net/note/delete/73724/bad+code
Del: spam -- https://master.php.net/note/delete/73724/spam
Del: non-english -- https://master.php.net/note/delete/73724/non-english
Del: in docs -- https://master.php.net/note/delete/73724/in+docs
Del: other reasons-- https://master.php.net/note/delete/73724
Reject -- https://master.php.net/note/reject/73724
Search -- https://master.php.net/manage/user-notes.php