ID:               6090
 Updated by:       [EMAIL PROTECTED]
 Reported By:      [EMAIL PROTECTED]
-Status:           Open
+Status:           Closed
 Bug Type:         Feature/Change Request
 Operating System: Linux
 PHP Version:      4.0.1pl2
 New Comment:

whole thing changed now with streams...


Previous Comments:
------------------------------------------------------------------------

[2002-04-01 19:20:36] [EMAIL PROTECTED]

Changed the subject since ftell() was fixed a while ago.
fseek() still returns 0 on success and -1 on error
which is not really the 'PHP way'. 


------------------------------------------------------------------------

[2000-08-10 22:43:23] [EMAIL PROTECTED]

On the second thought, it is - it should detect -1 return and return
false, but I'm not sure if it won't break something... So documentation
is right, code is wrong, I guess.

------------------------------------------------------------------------

[2000-08-10 22:25:46] [EMAIL PROTECTED]

Umm... what I want to say,
PHP's ftell function returns directly C's ftell().

So, this is "Documentation problem", isn't it?

Please see below... (Quote from /ext/standerd/file.c )
-----------------------------------
/* {{{ proto int fseek(int fp, int offset [, int whence])
   Seek on a file pointer */

PHP_FUNCTION(fseek)
{
        zval **arg1, **arg2, **arg3;
        int argcount = ARG_COUNT(ht), whence = SEEK_SET;
        void *what;
        
        if (argcount < 2 || argcount > 3 ||
            zend_get_parameters_ex(argcount, &arg1, &arg2, &arg3) == FAILURE)
{
                WRONG_PARAM_COUNT;
        }
        
        what =
zend_fetch_resource(arg1,-1,"File-Handle",NULL,2,le_fopen,le_popen);
        ZEND_VERIFY_RESOURCE(what);

        convert_to_long_ex(arg2);
        if (argcount > 2) {
                convert_to_long_ex(arg3);
                whence = (*arg3)->value.lval;
        }
        
        RETURN_LONG(fseek((FILE*)what, (*arg2)->value.lval, whence));
}

/* }}} */
-----------------------------------


------------------------------------------------------------------------

[2000-08-10 21:53:48] [EMAIL PROTECTED]

PHP functions return false on error. So I reclassify it to change
request.

------------------------------------------------------------------------

[2000-08-10 21:45:33] [EMAIL PROTECTED]

Quote from Linux Programmer's Manual fseek(3)...
>RETURN VALUES
> The  rewind  function  returns  no value.  Upon successful
> completion, fgetpos, fseek, fsetpos return  0,  and  ftell
> returns the current offset.  Otherwise, -1 is returned and
> the global variable errno is set to indicate the error.

So, we get 0(=false) if file position is begining of file.
But that's not error.


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=6090&edit=1

Reply via email to