note 88520 added to function.copy

From: Date: Tue, 27 Jan 2009 19:44:03 +0000
Subject: note 88520 added to function.copy
Groups: php.notes 
Request: Send a blank email to php-notes+get-149859@lists.php.net to get a copy of this message
When I recently had to copy a few millions of small files (< 1kb) from one NAS to another and for some reasons had to do that file by file I compared the following function with copy($src, $dest) and shell_exec("cp -r $src $dest"). Surprisingly stream_copy seamed to be slightly faster (at least in this specific context). function stream_copy($src, $dest) { $fsrc = fopen($src,'r'); $fdest = fopen($dest,'w+'); $len = stream_copy_to_stream($fsrc,$fdest); fclose($fsrc); fclose($fdest); return $len; } ---- Server IP: 69.147.83.197 Probable Submitter: 91.54.77.140 ---- Manual Page -- http://www.php.net/manual/en/function.copy.php Edit -- https://master.php.net/note/edit/88520 Del: integrated -- https://master.php.net/note/delete/88520/integrated Del: useless -- https://master.php.net/note/delete/88520/useless Del: bad code -- https://master.php.net/note/delete/88520/bad+code Del: spam -- https://master.php.net/note/delete/88520/spam Del: non-english -- https://master.php.net/note/delete/88520/non-english Del: in docs -- https://master.php.net/note/delete/88520/in+docs Del: other reasons-- https://master.php.net/note/delete/88520 Reject -- https://master.php.net/note/reject/88520 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#149859) next »