Simulate xcopy function
/***************************************
* System name: Function that simulates xcopy
* Program function: Simulate xcopy function
* Development date: 2003/03/14
****************************** ***********/
?>
//copy a direction's all files to another direction
function xCopy($source, $ destination, $child){
//Usage:
// xCopy("feiy","feiy2",1): Copy the files under feiy to feiy2, including subdirectories
// xCopy(" feiy","feiy2",0): Copy the files under feiy to feiy2, excluding subdirectories
//Parameter description:
// $source: source directory name
// $destination: destination Directory name
// $child: When copying, is it a subdirectory included?
if(!is_dir($source)){
echo("Error: the $source is not a direction!") ;
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;
}
?>