mirror of
https://github.com/php/php-src.git
synced 2025-08-18 15:08:55 +02:00
@-Add an optional third argument to fseek to indicate were to seek from. (Sterling)
This commit is contained in:
parent
e297737cb1
commit
21416083b1
1 changed files with 10 additions and 4 deletions
|
@ -1183,15 +1183,17 @@ PHP_FUNCTION(ftell)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* }}} */
|
/* }}} */
|
||||||
/* {{{ proto int fseek(int fp, int offset)
|
/* {{{ proto int fseek(int fp, int offset [, int seekfrom])
|
||||||
Seek on a file pointer */
|
Seek on a file pointer */
|
||||||
|
|
||||||
PHP_FUNCTION(fseek)
|
PHP_FUNCTION(fseek)
|
||||||
{
|
{
|
||||||
pval **arg1, **arg2;
|
pval **arg1, **arg2, **arg3;
|
||||||
|
int argcount = ARG_COUNT(ht), seekfrom = 0;
|
||||||
void *what;
|
void *what;
|
||||||
|
|
||||||
if (ARG_COUNT(ht) != 2 || zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) {
|
if (argcount < 2 || argcount > 3 ||
|
||||||
|
zend_get_parameters_ex(argcount, &arg1, &arg2, &arg3) == FAILURE) {
|
||||||
WRONG_PARAM_COUNT;
|
WRONG_PARAM_COUNT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1199,8 +1201,12 @@ PHP_FUNCTION(fseek)
|
||||||
ZEND_VERIFY_RESOURCE(what);
|
ZEND_VERIFY_RESOURCE(what);
|
||||||
|
|
||||||
convert_to_long_ex(arg2);
|
convert_to_long_ex(arg2);
|
||||||
|
if (argcount > 2) {
|
||||||
|
convert_to_long_ex(arg3);
|
||||||
|
seekfrom = (*arg3)->value.lval;
|
||||||
|
}
|
||||||
|
|
||||||
RETURN_LONG(fseek((FILE*)what,(*arg2)->value.lval,SEEK_SET));
|
RETURN_LONG(fseek((FILE*)what,(*arg2)->value.lval+seekfrom,SEEK_SET));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue