Simulate Xcopy's function instance code

Source: Internet
Author: User
xcopy is copy extension, you can copy the specified directory files and directory structure, but cannot copy system files, use the source drive, source destination pathname, source file name at least one, select/s when the source directory and all the files under the subdirectory copy. Unless you specify the/e parameter,/s does not copy an empty directory, and if you do not specify the/s parameter, xcopy copies only the files of the source directory itself, not the subdirectories below it, and when you choose the/v parameter, the copied sectors are checked, but the speed decreases.

<?php/************************************** system name: function to simulate xcopy * Program function: Simulate Xcopy's function *************************************/?><?//copy a direction ' s all files to another direction function XCopy ($source, $destination, $child) {//Usage://xcopy ("Feiy", "Feiy2", 1): Copy files under Feiy to Feiy2, including subdirectories//xcopy ("Feiy" , "Feiy2", 0): Copy files under Feiy to Feiy2, not including subdirectories//Parameter description://$source: Source directory Name//$destination: Destination directory Name//$child: When copying, is not included subdirectory 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; }; 
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.