added delete option to cpdir method.
This commit is contained in:
parent
ee400675d5
commit
87424c73f5
|
@ -179,9 +179,10 @@ public static function is($extensions, $path)
|
||||||
*
|
*
|
||||||
* @param string $source
|
* @param string $source
|
||||||
* @param string $destination
|
* @param string $destination
|
||||||
|
* @param bool $delete
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function cpdir($source, $destination)
|
public static function cpdir($source, $destination, $delete = false)
|
||||||
{
|
{
|
||||||
if ( ! is_dir($source)) return;
|
if ( ! is_dir($source)) return;
|
||||||
|
|
||||||
|
@ -208,6 +209,8 @@ public static function cpdir($source, $destination)
|
||||||
$path = $item->getRealPath();
|
$path = $item->getRealPath();
|
||||||
|
|
||||||
static::cpdir($path, $location);
|
static::cpdir($path, $location);
|
||||||
|
|
||||||
|
if ($delete) rmdir($item->getRealPath());
|
||||||
}
|
}
|
||||||
// If the file system item is an actual file, we can copy the
|
// If the file system item is an actual file, we can copy the
|
||||||
// file from the bundle asset directory to the public asset
|
// file from the bundle asset directory to the public asset
|
||||||
|
@ -216,8 +219,12 @@ public static function cpdir($source, $destination)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
copy($item->getRealPath(), $location);
|
copy($item->getRealPath(), $location);
|
||||||
|
|
||||||
|
if ($delete) unlink($item->getRealPath());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($delete) rmdir($source);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue