PHP
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

gztell> <gzrewind
Last updated: Fri, 22 Aug 2008

view this page in

gzseek

(PHP 4, PHP 5)

gzseekBusca en el archivo gz apuntado

Descripción

int gzseek ( resource $zp , int $offset )

Establece el indicador de posición del archivo para el apuntador de archivo. Equivalente a ejecutar (en C) gzseek(zp, offset, SEEK_SET).

Si el archivo es abierto para lectura, esta función es emulada pero puede ser extremadamente lenta. Si el archivo es abierto para escritura, solo se soportan b´squedas hacia adelante; gzseek() entonces comprime una secuencia de ceros hasta la nueva posición.

Lista de parámetros

zp

El apuntador de archivo gz. Debe ser válido, y debe apuntar a un archivo exitosamente abierto por gzopen().

offset

La posición a buscar.

Valores retornados

En caso de éxito, regresa 0; de otro modo, regresa -1. Note que si se pasa del fin del archivo no es considerado un error.

Ejemplos

Example #1 Ejemplo de gzseek()

<?php
$gz 
gzopen('somefile.gz''r');
gzseek($gz,2);
echo 
gzgetc($gz);
gzclose($gz);
?>

Ver también



add a note add a note User Contributed Notes
gzseek
dperham at wgate dot com
12-Apr-2005 08:47
PHP/4.3.9
contrary to the notes, gzseek() returns -1 if I try to seek past the end of the file.  here is a function that will return the last seekable position, and put the file pointer there.

/** sets the file pointer at the end of the file
 *  and returns the number of bytes in the file.
 */
function gzend($fh)
{
   $d   = 1<<14;
   $eof = $d;
   while ( gzseek($fh, $eof) == 0 ) $eof += $d;
   while ( $d > 1 )
   {
      $d >>= 1;
      $eof += $d * (gzseek($fh, $eof)? -1 : 1);
   }
   return $eof;
}

gztell> <gzrewind
Last updated: Fri, 22 Aug 2008
 
 
show source | credits | stats | sitemap | contact | advertising | mirror sites