|
@@ -1,4 +1,4 @@
|
|
|
-<?php namespace Laravel; use Closure;
|
|
|
+<?php namespace Laravel; use Closure, FilesystemIterator;
|
|
|
|
|
|
class File {
|
|
|
|
|
@@ -170,4 +170,51 @@ class File {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * Recursively copy directory contents to another directory.
|
|
|
+ *
|
|
|
+ * @param string $source
|
|
|
+ * @param string $destination
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public static function copy_dir($source, $destination)
|
|
|
+ {
|
|
|
+ if ( ! is_dir($source)) return;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if ( ! is_dir($destination))
|
|
|
+ {
|
|
|
+ mkdir($destination);
|
|
|
+ }
|
|
|
+
|
|
|
+ $items = new FilesystemIterator($source, FilesystemIterator::SKIP_DOTS);
|
|
|
+
|
|
|
+ foreach ($items as $item)
|
|
|
+ {
|
|
|
+ $location = $destination.DS.$item->getBasename();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if ($item->isDir())
|
|
|
+ {
|
|
|
+ $path = $item->getRealPath();
|
|
|
+
|
|
|
+ static::copy_dir($path, $location);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ else
|
|
|
+ {
|
|
|
+ copy($item->getRealPath(), $location);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|