1
0
Fork 0

using mkdir() in copyThenRemove() leads to errors if the target exists or not a dir, use ensureDirectoryExists() instead

pull/2279/head
Karoly Negyesi 2013-09-20 05:02:06 +02:00
parent b333d7a485
commit dd4db91ae7
1 changed files with 2 additions and 5 deletions

View File

@ -129,15 +129,12 @@ class Filesystem
{
$it = new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS);
$ri = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::SELF_FIRST);
if (!file_exists($target)) {
mkdir($target, 0777, true);
}
$this->ensureDirectoryExists($target);
foreach ($ri as $file) {
$targetPath = $target . DIRECTORY_SEPARATOR . $ri->getSubPathName();
if ($file->isDir()) {
mkdir($targetPath);
$this->ensureDirectoryExists($targetPath);
} else {
copy($file->getPathname(), $targetPath);
}