note 23951 deleted from function.copy by dams
| From: | dams@php.net | Date: | Sat, 03 Aug 2002 03:07:42 +0000 |
| Subject: | note 23951 deleted from function.copy by dams | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-34190@lists.php.net to get a copy of this message | ||
My version of copy (can copy a directory, the destination will have the identical permissions as the
source).
function weave_copy($from_path, $to_path)
{
if(file_exists($to_path))
return false;
if(is_dir($from_path))
{
if(($dir = @opendir($from_path)) != false)
{
$success = @mkdir($to_path, @fileperms($from_path));
while (($file = readdir($dir)) !== false)
{
if($file != '.' && $file != '..')
$success = weave_copy("$from_path/$file", "$to_path/$file")
&& $success;
}
closedir($dir);
return $success;
}
else
return false;
}
else if(is_file($from_path))
return @copy($from_path, $to_path) && @chmod($to_path, @fileperms($from_path));
return true;
}