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

 ID:                 52335
 Updated by:         cataphr...@php.net
 Reported by:        jbondc at openmv dot com
 Summary:            fseek() on memory stream behavior different then
                     file
 Status:             Assigned
-Type:               Documentation Problem
+Type:               Bug
-Package:            Documentation problem
+Package:            Streams related
 Operating System:   FreeBSD 7.2
 PHP Version:        5.2.14RC2
 Assigned To:        cataphract
 Block user comment: N

 New Comment:

I've fixed the doc part, but on a closer inspection the behavior of the
memory stream on past-the-end-of-file seeks could be improved.


Previous Comments:
------------------------------------------------------------------------
[2010-11-13 16:09:54] cataphr...@php.net

Automatic comment from SVN on behalf of cataphract
Revision: http://svn.php.net/viewvc/?view=revision&revision=305317
Log: - Behavior when seeking past the end of file.
  Partially addresses bug #52335.
- Expanded note on how the stream may not support seeking.

------------------------------------------------------------------------
[2010-07-14 13:18:10] jbondc at openmv dot com

Description:
------------
May not be a bug but a documentation issue



With a file, fseek() to an offset that doesn't exist results in NULL
bytes added.

Using a memory stream, fseek() just fails.



Which one is the expected behavior? Also for
streamWrapper::stream_seek()















Test script:
---------------
$sp = fopen("php://memory", 'w+');

fseek($sp, 1024);               // fails why?

echo fwrite($sp, "abc");        // 3

fseek($sp, 1024);               //

echo fread($sp, 3);             // NULL.. 



$sp = fopen("/tmp/foo", 'w+');

fseek($sp, 1024);

echo fwrite($sp, "abc");        // 3

fseek($sp, 1024);

echo fread($sp, 3);             // abc

Expected result:
----------------
3abc3abc

Actual result:
--------------
33abc


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



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

Reply via email to