note 101033 added to function.fseek
| From: | shehi at imanov dot name | Date: | Mon, 22 Nov 2010 11:46:28 +0000 |
| Subject: | note 101033 added to function.fseek | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-174244@lists.php.net to get a copy of this message | ||
@ sylvain at abstraction dot fr :
Afraid not, your code won't work on 32-bit PHP compilation, even if you try to bypass it that
way. Another approach is as follows, which doesn't work either [guess internal pointer or
something similar in PHP's fseek() still uses 4-byte signed integer, so no matter what we try
it doesn't seek] :
function file__fseek_safe ( $file_handler , $position )
{
if ( bccomp( $position, "2147483647" ) == 1 )
{
if ( ( $return = fseek( $file_handler, 0, SEEK_SET ) ) != 0 )
{
return $return;
}
while( bccomp( $position, 0 ) == 1 )
{
$_bytes = "2147483647";
if ( bccomp( $_bytes, $position ) == 1 )
{
$_bytes = $position;
}
if ( ( $return = fseek( $file_handler, intval( $_bytes ), SEEK_CUR ) ) != 0 )
{
return $return;
}
$position = bcsub( $position, $_bytes );
}
return 0;
}
else
{
return fseek( $file_handler, intval( $position ), SEEK_SET );
}
}
----
Server IP: 69.147.83.197
Probable Submitter: 78.182.217.52
----
Manual Page -- http://www.php.net/manual/en/function.fseek.php
Edit -- https://master.php.net/note/edit/101033
Del: integrated -- https://master.php.net/note/delete/101033/integrated
Del: useless -- https://master.php.net/note/delete/101033/useless
Del: bad code -- https://master.php.net/note/delete/101033/bad+code
Del: spam -- https://master.php.net/note/delete/101033/spam
Del: non-english -- https://master.php.net/note/delete/101033/non-english
Del: in docs -- https://master.php.net/note/delete/101033/in+docs
Del: other reasons-- https://master.php.net/note/delete/101033
Reject -- https://master.php.net/note/reject/101033
Search -- https://master.php.net/manage/user-notes.php