#47997 [Opn->Ver]: stream_copy_to_stream returns 1 on empty streams
| From: | jani@php.net | Date: | Fri, 17 Apr 2009 11:08:31 +0000 |
| Subject: | #47997 [Opn->Ver]: stream_copy_to_stream returns 1 on empty streams | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-135921@lists.php.net to get a copy of this message | ||
ID: 47997
Updated by: jani@php.net
Reported By: robots at shad dot pp dot ru
-Status: Open
+Status: Verified
Bug Type: Streams related
-Operating System: Windows Server 2003
+Operating System: *
PHP Version: 5.2.9
New Comment:
From streams.c:
"in the event that the source file is 0 bytes, return 1 to indicate
success because opening the file to write had already created a copy"
Looks like yet another design flaw in the streams API.
Previous Comments:
------------------------------------------------------------------------
[2009-04-16 23:52:46] robots at shad dot pp dot ru
Description:
------------
Function returns 1 even if used to copy empty stream.
Reproduce code:
---------------
<?php
// Creating empty file
$src = fopen('srcfile.tmp', 'w+');
fclose($src);
$src = fopen('srcfile.tmp', 'r');
$dst = fopen('dstfile.tmp', 'w+');
echo stream_copy_to_stream($src, $dst);
fclose($src);
fclose($dst);
?>
Expected result:
----------------
0
Actual result:
--------------
1
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=47997&edit=1