From f7e6b957de5fe38c727237c8eb313a94eeeae641 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 18 Jan 2012 09:18:37 -0600 Subject: [PATCH] added function to recursively copy a directory. --- laravel/cli/tasks/bundle/publisher.php | 37 ++----------------- laravel/file.php | 49 +++++++++++++++++++++++++- 2 files changed, 50 insertions(+), 36 deletions(-) diff --git a/laravel/cli/tasks/bundle/publisher.php b/laravel/cli/tasks/bundle/publisher.php index 10ef595f..ef7eeeb9 100644 --- a/laravel/cli/tasks/bundle/publisher.php +++ b/laravel/cli/tasks/bundle/publisher.php @@ -1,5 +1,6 @@ isDir()) - { - $path = $item->getRealPath(); - - $recurse = str_replace($this->from($bundle), $this->to($bundle), $path); - - $this->move($bundle, $path, $recurse); - } - // If the file system item is an actual file, we can copy the - // file from the bundle asset directory to the public asset - // directory. The "copy" method will overwrite any existing - // files with the same name. - else - { - copy($item->getRealPath(), $destination.DS.$item->getBasename()); - } - } + File::copy_dir($source, $destination); } /** diff --git a/laravel/file.php b/laravel/file.php index a1e7a724..ec2f1fa7 100644 --- a/laravel/file.php +++ b/laravel/file.php @@ -1,4 +1,4 @@ -getBasename(); + + // If the file system item is a directory, we will recurse the + // function, passing in the item directory. To get the proper + // destination path, we'll add the basename of the source to + // to the destination directory. + if ($item->isDir()) + { + $path = $item->getRealPath(); + + static::copy_dir($path, $location); + } + // If the file system item is an actual file, we can copy the + // file from the bundle asset directory to the public asset + // directory. The "copy" method will overwrite any existing + // files with the same name. + else + { + copy($item->getRealPath(), $location); + } + } + } + + } \ No newline at end of file