note 26731 deleted from function.copy by aidan

From: Date: Mon, 30 Aug 2004 07:27:48 +0000
Subject: note 26731 deleted from function.copy by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-75646@lists.php.net to get a copy of this message
Note Submitter: michael at zend dot com ---- This set of functions copies all files, directories (even they are full) may be usefull. <?php 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); } ?>

« previous php.notes (#75646) next »