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, 09 May 2008

view this page in

gzseek

(PHP 4, PHP 5)

gzseek — Перемещает индикатор позиции в gz-файле

Описание

int gzseek ( resource $zp , int $offset )

Устанавливает индикатор позиции файла, на который ссылается zp, в смещение в байтах потока этого файла. Эквивалентно вызову (на C) gzseek(zp, offset, SEEK_SET).

Если файл открыт для чтения, эта функция симулируется, но будет работать очень медленно. Если файл открыт для записи, разрешён только поиск вперёд; gzseek() при этом сжимает последовательность нулей до новой позиции.

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

zp

Указатель на gz-файл, возвращённый, после его успешного открытия, функцией gzopen().

offset

Смещение.

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

При успешном завершении возвращает 0; иначе -1. Обратите внимание, что если смещение стоит после EOF, это не является ошибкой.

Смотрите также



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, 09 May 2008
 
 
show source | credits | stats | sitemap | contact | advertising | mirror sites