42 lines
838 B
PHP
42 lines
838 B
PHP
<?php
|
|
|
|
/**
|
|
* Namespace for Folder related classes and functions.
|
|
* @package NAE\Functions\Folder
|
|
*/
|
|
namespace NAE\Functions\Folder;
|
|
|
|
/**
|
|
* Recursive copy a directory and its contents to another directory (overwrites existing structures).
|
|
* @param string $source Quellpfad/URL
|
|
* @param string $destination Zielpfad
|
|
*/
|
|
function rcopy(string $source, string $destination) {
|
|
|
|
if (file_exists($destination)) {
|
|
|
|
rrmdir($destination);
|
|
return;
|
|
|
|
}
|
|
if (is_dir($source)) {
|
|
|
|
mkdir($destination);
|
|
$files = scandir($source);
|
|
foreach ($files as $file) {
|
|
if ($file != "." && $file != "..") {
|
|
rcopy("$source/$file", "$destination/$file");
|
|
}
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
if (file_exists($source)) {
|
|
|
|
copy($source, $destination);
|
|
|
|
}
|
|
|
|
}
|