diff options
| author | polo-pc-greta <ordipolo@gmx.fr> | 2025-03-27 10:13:03 +0100 |
|---|---|---|
| committer | polo-pc-greta <ordipolo@gmx.fr> | 2025-03-27 10:13:03 +0100 |
| commit | df3612ed7e6691530503f79483d2fdbc032d01b8 (patch) | |
| tree | 56d1c68fdc8625f5dad1937a654299d45142c79a /bin/copy_directory.php | |
| download | cms-df3612ed7e6691530503f79483d2fdbc032d01b8.tar.gz cms-df3612ed7e6691530503f79483d2fdbc032d01b8.tar.bz2 cms-df3612ed7e6691530503f79483d2fdbc032d01b8.zip | |
mise en ligne github
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]); | ||
