Skip to content

Commit 30c5b15

Browse files
committed
Use stream_copy_to_stream().
1 parent 5fbe927 commit 30c5b15

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

src/Adapter/Local.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,7 @@ public function writeStream($path, $resource, Config $config)
104104
return false;
105105
}
106106

107-
while (! feof($resource)) {
108-
fwrite($stream, fread($resource, 1024), 1024);
109-
}
107+
stream_copy_to_stream($resource, $stream);
110108

111109
if (! fclose($stream)) {
112110
return false;

tests/LocalAdapterTests.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44

55
use League\Flysystem\Config;
66

7-
function fopen($result)
7+
function fopen($result, $mode)
88
{
99
if (substr($result, -5) === 'false') {
1010
return false;
1111
}
1212

1313
if (substr($result, -5) === 'dummy') {
14-
return 'dummy';
14+
return fopen('data://text/plain,', $mode);
1515
}
1616

1717
return call_user_func_array('fopen', func_get_args());
@@ -28,7 +28,7 @@ function fwrite($result)
2828

2929
function fclose($result)
3030
{
31-
if (is_string($result) and substr($result, -5) === 'dummy') {
31+
if (is_resource($result) && stream_get_meta_data($result)['stream_type'] === 'RFC2397') {
3232
return false;
3333
}
3434

0 commit comments

Comments
 (0)