-/* {{{ proto long stream_copy_to_stream(resource source, resource dest [,
long maxlen ])
+/* {{{ proto long stream_copy_to_stream(resource source, resource dest [,
long maxlen [, long pos]])
Reads up to maxlen bytes from source stream and writes them to dest
stream. */
PHP_FUNCTION(stream_copy_to_stream)
{
php_stream *src, *dest;
zval *zsrc, *zdest;
- long maxlen = PHP_STREAM_COPY_ALL;
+ long maxlen = PHP_STREAM_COPY_ALL, pos = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rr|l", &zsrc,
&zdest, &maxlen) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rr|ll", &zsrc,
&zdest, &maxlen, &pos) == FAILURE) {
RETURN_FALSE;
}
php_stream_from_zval(src, &zsrc);
php_stream_from_zval(dest, &zdest);
+ if (pos > 0 && php_stream_seek(src, pos, SEEK_SET) < 0) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to seek to %ld
position in the stream.", pos);
+ RETURN_FALSE;
+ }
And what if you set the 'pos' parameter to 0? It won't seek the stream that
way. You could change to:
'long pos = -1;'
and
if (pos >= 0 ...'
Nuno
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php