Since seek after the end is not considered an error, I doubt that "while (gzseek ($fh, $eof) == 0) $eof += $d;" will get into infinite loop.(PHP 4, PHP 5, PHP 7, PHP 8)
gzseek — Gzipli dosya göstericisini konumlar
Belirtilen dosya tanıtıcısında dosya göstericisini belirtilen konuma taşır.
gzseek(dt, konum, SEEK_SET) C çağrısına eşdeğerdir.
Dosya okumak için açılmışsa bu işlev yine de taklit edilir ama işlem oldukça yavaşlar. Dosya yazmak için açılmışsa sadece ileri yönde konumlamalar desteklenir; gzseek() konumlamanın ardından yeni konuma kadar olan bölgeyi sıfırlarla doldurur.
dtGzipli dosya tanıtıcısı. gzopen() tarafından açılmış bir dosyayı gösteren geçerli bir tanıtıcı olmalıdır.
konumGöstericinin götürüleceği konum.
nereye
Olası nereye değerleri:
SEEK_SET - Gösterici, tam
konumuncu bayta yerleştirilir.SEEK_CUR - Gösterici, mevcut
konum artı konumuncu bayta yerleştirilir.
nereye bağımsız değişkeni belirtilmezse
SEEK_SET belirtilmiş gibi işlem yapılır.
Başarı durumunda 0, aksi takdirde -1 döner. Dosya sonunun sonrasına yapılan bir konumlama bir hata olarak değerlendirilmez.
Örnek 1 - gzseek() örneği
<?php
$gz = gzopen('birdosya.gz', 'r');
gzseek($gz,2);
echo gzgetc($gz);
gzclose($gz);
?>
Since seek after the end is not considered an error, I doubt that "while (gzseek ($fh, $eof) == 0) $eof += $d;" will get into infinite loop.PHP/4.3.9contrary 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;}