/*Copy xCopy 関数の使用法:
* xCopy("feiy","feiy2",1): feiy の下にあるファイルをコピーしますfeiy2 (サブディレクトリを含む)
* xCopy("feiy","feiy2",0): feiy 配下のファイルをサブディレクトリを除いて feiy2 にコピーします
*パラメータの説明:
* $source: コピー元のディレクトリ名
* $destination: コピー先のディレクトリ名
* $child: コピーする場合、サブディレクトリも含まれますか?
*/
function xCopy($source, $destination, $child){
if (!file_exists($destination))
{
($destination, '/ ')、0777))
' ;
}
if(!is_dir($source)){
return 0;
}
if(!is_dir($destination)){
mkdir ($destination,0777);
$handle=dir($source);
while($entry=$handle->read()){
if(($entry!=".")&&($entry!="..")) {
if(is_dir($source." /".$entry)){
if($child)
xCopy($source."/".$entry,$destination."/".$entry,$child) ;
}
else{
copy($source."/".$entry,$destination."/".$entry);
}
}
}
return 1;
}
/* deldir 関数の使用法を削除します:
* deldidr("feiy"): サブディレクトリを含む feiy を削除します
* パラメータの説明: * $dir: 削除するディレクトリの名前
*/
function deldir($dir ) {
if (!file_exists($dir)){return true;
}else{@chmod($dir, 0777);}
$dh=opendir($dir);
while ($file=readdir($dh) )) {
if($file!="." && $file!="..") {
$fullpath=$dir."/".$file;
if(!is_dir($fullpath)) {
unlink( $fullpath);
} else {
Closedir($dh);
if(rmdir($dir)) {
return true;
} else {
return false;
}
}
?>
http://www.bkjia.com/PHPjc/326538.html
www.bkjia.com