類比xcopy的函數執行個體代碼

來源:互聯網
上載者:User
XCOPY是COPY的擴充,可以把指定的目錄連檔案和目錄結構一併拷貝,但不能拷貝系統檔案;使用時來源硬碟符、源目標路徑名、源檔案名稱至少指定一個;選用/S時對來源目錄下及其子目錄下的所有檔案進行COPY。除非指定/E參數,否則/S不會拷貝空目錄,若不指定/S參數,則XCOPY只拷貝來源目錄本身的檔案,而不涉及其下的子目錄;選用/V參數時,對拷貝的扇區都進行較驗,但速度會降低。

<?php /************************************** 系統名稱:類比xcopy的函數* 程式功能:類比xcopy的函數*************************************/?><?//copy a direction's all files to another direction function xCopy($source, $destination, $child){ //用法: // xCopy("feiy","feiy2",1):拷貝feiy下的檔案到 feiy2,包括子目錄 // xCopy("feiy","feiy2",0):拷貝feiy下的檔案到 feiy2,不包括子目錄 //參數說明: // $source:來源目錄名 // $destination:目的目錄名 // $child:複製時,是不是包含的子目錄 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; } ?>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.