note 112646 deleted from function.fseek by daverandom
| From: | daverandom@php.net | Date: | Mon, 10 Feb 2014 12:08:00 +0000 |
| Subject: | note 112646 deleted from function.fseek by daverandom | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-198446@lists.php.net to get a copy of this message | ||
Note Submitter: anonymous at php dot net
----
how to read BIG files using fseek (above 2GB+, upto any size like 4GB+, 100GB+, 100 terabyes+, any
file size, 100 petabytes, max limit is php_float_max ) ?
// seek / set file pointer to 50 GB
my_fseek($fp, floatval(50000000000),1);
function my_fseek($fp,$pos,$first=0) {
// set to 0 pos initially, one-time
if($first) fseek($fp,0,SEEK_SET);
// get pos float value
$pos=floatval($pos);
// within limits, use normal fseek
if($pos<=PHP_INT_MAX)
fseek($fp,$pos,SEEK_CUR);
// out of limits, use recursive fseek
else {
fseek($fp,PHP_INT_MAX,SEEK_CUR);
$pos -= PHP_INT_MAX;
my_fseek($fp,$pos);
}
}
hope this helps.