Re: cvs: php-src / NEWS /ext/standard streamsfuncs.c

From: Date: Wed, 22 Jun 2005 19:08:47 +0000
Subject: Re: cvs: php-src / NEWS /ext/standard streamsfuncs.c
References: 1  Groups: php.cvs 
Request: Send a blank email to php-cvs+get-32479@lists.php.net to get a copy of this message
-/* {{{ 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

« previous php.cvs (#32479) next »