note 26731 added to function.copy

From: Date: Mon, 11 Nov 2002 08:23:24 +0000
Subject: note 26731 added to function.copy
Groups: php.notes 
Request: Send a blank email to php-notes+get-39286@lists.php.net to get a copy of this message
This set of functions copies all files, directories (even they are full) may be usefull. function my_copy($oldname, $newname) { if(is_file($oldname)){ $perms = fileperms($oldname); return copy($oldname, $newname) && chmod($newname, $perms); } else if(is_dir($oldname)){ my_dir_copy($oldname, $newname); } else{ die("Cannot copy file: $oldname (it's neither a file nor a directory)"); } } function my_dir_copy($oldname, $newname) { if(!is_dir($newname)){ mkdir($newname); } $dir = opendir($oldname); while($file = readdir($dir)){ if($file == "." || $file == ".."){ continue; } my_copy("$oldname/$file", "$newname/$file"); } closedir($dir); } -- http://www.php.net/manual/en/function.copy.php http://master.php.net/manage/user-notes.php?action=edit+26731 http://master.php.net/manage/user-notes.php?action=delete+26731 http://master.php.net/manage/user-notes.php?action=reject+26731

« previous php.notes (#39286) next »