Simulate xcopy functions <? Php
/*************************************
* System name: Simulate xcopy Function
* Program function: simulates xcopy functions.
* Development Date: 2003/03/14
*************************************/
?>
<?
// Copy a ction's all files to another direction
Function xCopy ($ source, $ destination, $ child ){
// Usage:
// XCopy ("feiy", "feiy2", 1): copy the file under feiy to feiy2, including subdirectories
// XCopy ("feiy", "feiy2", 0): copy the file under feiy to feiy2, excluding subdirectories.
// Parameter description:
// $ Source: source directory name
// $ Destination: name of the target directory
// $ Child: indicates whether the subdirectory is included during replication.
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;
}
?>