note 54197 added to function.copy

From: Date: Mon, 27 Jun 2005 07:52:28 +0000
Subject: note 54197 added to function.copy
Groups: php.notes 
Request: Send a blank email to php-notes+get-90998@lists.php.net to get a copy of this message
These functions are to copy and remove big directories: /* source files are in source directory */ function SetupFolder($dir_name) { mkdir($dir_name,'0777'); $folder = opendir('source'); while($file = readdir($folder)) { if ($file == '.' || $file == '..') { continue; } if(is_dir('source/'.$file)) { mkdir($dir_name.'/'.$file,0777); CopyFiles('source/'.$file,$dir_name.'/'.$file); } else { copy('source/'.$file,$dir_name.'/'.$file); } } closedir($folder); return 1; } //copy many files function CopyFiles($source,$dest) { $folder = opendir($source); while($file = readdir($folder)) { if ($file == '.' || $file == '..') { continue; } if(is_dir($source.'/'.$file)) { mkdir($dest.'/'.$file,0777); CopySourceFiles($source.'/'.$file,$dest.'/'.$file); } else { copy($source.'/'.$file,$dest.'/'.$file); } } closedir($folder); return 1; } //remove file, directories, subdirectories function RemoveFiles($source) { $folder = opendir($source); while($file = readdir($folder)) { if ($file == '.' || $file == '..') { continue; } if(is_dir($source.'/'.$file)) { RemoveFiles($source.'/'.$file); } else { unlink($source.'/'.$file); } } closedir($folder); rmdir($source); return 1; } ---- Manual Page -- http://www.php.net/manual/en/function.copy.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+54197 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+54197&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+54197&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+54197&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+54197&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+54197&report=yes&reason=non-english Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+54197&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+54197&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#90998) next »