note 101033 deleted from function.fseek by danbrown

From: Date: Mon, 22 Nov 2010 13:56:30 +0000
Subject: note 101033 deleted from function.fseek by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-174251@lists.php.net to get a copy of this message
Note Submitter: shehi at imanov dot name ---- @ 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 ); } }

« previous php.notes (#174251) next »