diff options
Diffstat (limited to 'bin/copy_directory.php')
| -rw-r--r-- | bin/copy_directory.php | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/bin/copy_directory.php b/bin/copy_directory.php new file mode 100644 index 0000000..2c001c0 --- /dev/null +++ b/bin/copy_directory.php | |||
| @@ -0,0 +1,25 @@ | |||
| 1 | <?php | ||
| 2 | // bin/copy_directory.php | ||
| 3 | // | ||
| 4 | // appel dans le composer.json | ||
| 5 | |||
| 6 | function copyDirectory($source, $destination) { | ||
| 7 | if (!is_dir($destination)) { | ||
| 8 | mkdir($destination, 0777, true); | ||
| 9 | } | ||
| 10 | |||
| 11 | $iterator = new RecursiveIteratorIterator( | ||
| 12 | new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS), | ||
| 13 | RecursiveIteratorIterator::SELF_FIRST | ||
| 14 | ); | ||
| 15 | |||
| 16 | foreach ($iterator as $item) { | ||
| 17 | if ($item->isDir()) { | ||
| 18 | mkdir($destination . DIRECTORY_SEPARATOR . $iterator->getSubPathName()); | ||
| 19 | } else { | ||
| 20 | copy($item, $destination . DIRECTORY_SEPARATOR . $iterator->getSubPathName()); | ||
| 21 | } | ||
| 22 | } | ||
| 23 | } | ||
| 24 | |||
| 25 | copyDirectory($argv[1], $argv[2]); | ||
