Web студия "GrandView"
  Главная   Написать Контакты
   
   
О проекте
Руководство php
 

zip_entry_read

(PHP 4 >= 4.1.0, PECL)

zip_entry_read -- Read from an open directory entry

Описание

string zip_entry_read ( resource zip_entry [, int length] )

Reads from an open directory entry.

Список параметров

zip_entry

A directory entry returned by zip_read().

length

The number of bytes to return. If not specified, this function will attempt to read 1024 bytes.

Замечание: This should be the uncompressed length you wish to read.

Возвращаемые значения

Returns the data read, or FALSE if the end of the file is reached.



add a note add a note User Contributed Notes
zip_entry_read
Radon8472
16-Aug-2007 05:03
I`ve got a big Problem with the "zip_entry_read" function, and I don`t unterstand what I did wrong.
I tried to write a function, wicht reads all zip Entries of a file into an Array. It worked, I can read alle Methadata from this array.
But when i try to read the content, I always get nothing.

This is an example whre you can see whats the problem:

when I read 10 Bytes content IN the funktion, it works, but when I try the same with the returnvalue (or with the refference of the entries), it won`t work.

With the result of the function, I can also read all the methadata (filename, size ...) but only the Content, seems to be emty after the function.

<?php
 
require("zip_funct.inc.php");

  function
test(&$zip_entry = null)
  {
   
$zip = zip_open("test.zip");
    while(
$tmp[] = zip_read($zip) );
   
array_pop($tmp);
   
$zip_entry = $tmp;

   
$n = 2;
   
var_dump($zip_entry);

   
$buf = zip_entry_read($zip_entry[$n], 10);
    echo
"CONTENT:\n------------------\n".$buf."\n";
    echo
"------------------\n";
    echo
"Name:               " . zip_entry_name($zip_entry[$n]) . "\n";
    echo
"Actual Filesize:    " . zip_entry_filesize($zip_entry[$n]) . "\n";
    echo
"Compressed Size:    " . zip_entry_compressedsize($zip_entry[$n]) . "\n";
    echo
"Compression Method: " . zip_entry_compressionmethod($zip_entry[$n]) . "\n";

//    echo fread($result, 50);
   
return $zip_entry;
}

// ##################################################

//  test($zip_entry);  // try to get the zip_entries via Refference
   
$zip_entry = test();  // try to get zip_entries s return value

   
$n = 2;
   
var_dump($zip_entry);

   
$buf = zip_entry_read($zip_entry[$n], 10);
    echo
"CONTENT:\n------------------\n".$buf."\n";
    echo
"------------------\n";
    echo
"Name:               " . zip_entry_name($zip_entry[$n]) . "\n";
    echo
"Actual Filesize:    " . zip_entry_filesize($zip_entry[$n]) . "\n";
    echo
"Compressed Size:    " . zip_entry_compressedsize($zip_entry[$n]) . "\n";
    echo
"Compression Method: " . zip_entry_compressionmethod($zip_entry[$n]) . "\n";
?>

The screenoutput looks like this:

array(8) {
  [0]=>
  resource(61) of type (Zip Entry)
  [1]=>
  resource(62) of type (Zip Entry)
// and a lot other entries
}
CONTENT:
------------------
<html>
<h
------------------
Name:               tmp.html
Actual Filesize:    1136
Compressed Size:    360
Compression Method: deflated
array(8) {
  [0]=>
  resource(61) of type (Zip Entry)
  [1]=>
  resource(62) of type (Zip Entry)
// and a lot other entries
}
CONTENT:
------------------

------------------
Name:               tmp.html
Actual Filesize:    1136
Compressed Size:    360
Compression Method: deflated

And this output shows, that the returnvalue of the function still as a valid ressource and still returns the correct methadata, but the content is empty.

I try to solve this problem since weeks and I realy need help. If anybody has an idea whats the Problem, please notice hear.
Matt
16-Nov-2005 04:53
When reading from a zip file if the initial call to zip_entry_read() returns false it would be advisable to run mkdir with the file name since it it very likely that the zero length file was a directory and attempts to save the files within the directory will fail if you dont create it first

zip_open> <zip_entry_open
Last updated: Fri, 26 Jan 2007
 
 
Новости
11 июля 2007
Сайт запущен
© 2007 info@grandviewstudio.com

Deprecated: Function set_magic_quotes_runtime() is deprecated in /home/sites/grandviewstudiocom/www/65f67d67a94ad980786580ae69e11c07/sape.php on line 324

Deprecated: Function set_magic_quotes_runtime() is deprecated in /home/sites/grandviewstudiocom/www/65f67d67a94ad980786580ae69e11c07/sape.php on line 330
Z058440144362 Z348613067571