note 44500 added to function.copy
| From: | walaces at uol dot com dot br | Date: | Sun, 08 Aug 2004 04:02:13 +0000 |
| Subject: | note 44500 added to function.copy | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-74191@lists.php.net to get a copy of this message | ||
This function will copy all entries in source diretory to destin directory recursively, including
other directories.
<?php
function copy_dir($_s_dir,$_d_dir) {
if(!is_dir($_s_dir)) {
return FALSE;
}
$_od = getcwd(); // Devemos guardar o diretório atual...
chdir($_s_dir);
$_d = @opendir("./");
$_ret = TRUE;
while (($_l=readdir($_d))!==FALSE) {
if(substr($_l,0,1)=="." AND strlen($_l)<=2) {
continue;
}
if(is_dir($_l)) {
mkdir("$_d_dir/$_l");
if(!copy_dir("$_s_dir/$_l","$_d_dir/$_l")) {
$_ret = FALSE;
}
}
else {
if(!copy($_l,"$_d_dir/$_l")) {
$_ret = FALSE;
}
}
}
closedir($_d);
chdir($_od);
return $_ret;
}
?>
----
Manual Page -- http://www.php.net/manual/en/function.copy.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+44500
Delete -- http://master.php.net/manage/user-notes.php?action=delete+44500&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+44500&report=yes
Search -- http://master.php.net/manage/user-notes.php