Browse Source

Merge pull request #371 from daylerees/patch-1

Allow File::cpdir() to return false on failure.
Taylor Otwell 12 years ago
parent
commit
ea8d80d67d
1 changed files with 6 additions and 4 deletions
  1. 6 4
      laravel/file.php

+ 6 - 4
laravel/file.php

@@ -183,7 +183,7 @@ class File {
 	 */
 	public static function mvdir($source, $destination, $options = fIterator::SKIP_DOTS)
 	{
-		static::cpdir($source, $destination, true, $options);
+		return static::cpdir($source, $destination, true, $options);
 	}
 
 	/**
@@ -197,7 +197,7 @@ class File {
 	 */
 	public static function cpdir($source, $destination, $delete = false, $options = fIterator::SKIP_DOTS)
 	{
-		if ( ! is_dir($source)) return;
+		if ( ! is_dir($source)) return false;
 
 		// First we need to create the destination directory if it doesn't
 		// already exists. This directory hosts all of the assets we copy
@@ -221,7 +221,7 @@ class File {
 			{
 				$path = $item->getRealPath();
 
-				static::cpdir($path, $location, $delete, $options);
+				if (! static::cpdir($path, $location, $delete, $options)) return false;
 
 				if ($delete) @rmdir($item->getRealPath());
 			}
@@ -231,13 +231,15 @@ class File {
 			// files with the same name.
 			else
 			{
-				copy($item->getRealPath(), $location);
+				if(! copy($item->getRealPath(), $location)) return false;
 
 				if ($delete) @unlink($item->getRealPath());
 			}
 		}
 
 		if ($delete) rmdir($source);
+		
+		return true;
 	}
 
 	/**