Skip to content

Commit

Permalink
[FrameworkBundle] fixed Filesystem when used within a phar archive
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Sep 23, 2010
1 parent a01a74e commit d62befd
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/Symfony/Bundle/FrameworkBundle/Util/Filesystem.php
Expand Up @@ -37,10 +37,7 @@ public function copy($originFile, $targetFile, $options = array())
$options['override'] = false;
}

// we create target_dir if needed
if (!is_dir(dirname($targetFile))) {
$this->mkdirs(dirname($targetFile));
}
$this->mkdirs(dirname($targetFile));

$mostRecent = false;
if (file_exists($targetFile)) {
Expand Down Expand Up @@ -206,8 +203,16 @@ public function mirror($originDir, $targetDir, \Traversable $iterator = null, $o
$iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($originDir, \FilesystemIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST);
}

if ('/' === substr($targetDir, -1) || '\\' === substr($targetDir, -1)) {
$targetDir = substr($targetDir, 0, -1);
}

if ('/' === substr($originDir, -1) || '\\' === substr($originDir, -1)) {
$originDir = substr($originDir, 0, -1);
}

foreach ($iterator as $file) {
$target = $targetDir.DIRECTORY_SEPARATOR.str_replace(realpath($originDir), '', $file->getRealPath());
$target = $targetDir.'/'.str_replace($originDir.'/', '', $file->getPathname());

if (is_dir($file)) {
$this->mkdirs($target);
Expand Down

0 comments on commit d62befd

Please sign in to comment.