note 23951 added to function.copy
| From: | hawcue at yahoo dot com | Date: | Fri, 02 Aug 2002 03:20:38 +0000 |
| Subject: | note 23951 added to function.copy | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-34118@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;
}
--
http://www.php.net/manual/en/function.copy.php
http://master.php.net/manage/user-notes.php?action=edit+23951
http://master.php.net/manage/user-notes.php?action=delete+23951
http://master.php.net/manage/user-notes.php?action=reject+23951