Skip to content

Commit

Permalink
Fix archiving paths on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Seldaek committed May 10, 2016
1 parent 046c2d6 commit 5cb3564
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/Composer/Package/Archiver/ZipArchiver.php
Expand Up @@ -13,6 +13,7 @@
namespace Composer\Package\Archiver;

use ZipArchive;
use Composer\Util\Filesystem;

/**
* @author Jan Prieser <jan@prieser.net>
Expand All @@ -28,15 +29,17 @@ class ZipArchiver implements ArchiverInterface
*/
public function archive($sources, $target, $format, array $excludes = array())
{
$sources = realpath($sources);
$fs = new Filesystem();
$sources = $fs->normalizePath($sources);

$zip = new ZipArchive();
$res = $zip->open($target, ZipArchive::CREATE);
if ($res === true) {
$files = new ArchivableFilesFinder($sources, $excludes);
foreach ($files as $file) {
/** @var $file \SplFileInfo */
$filepath = $file->getPath()."/".$file->getFilename();
$localname = str_replace($sources."/", '', $filepath);
$filepath = strtr($file->getPath()."/".$file->getFilename(), '\\', '/');
$localname = str_replace($sources.'/', '', $filepath);
if ($file->isDir()) {
$zip->addEmptyDir($localname);
} else {
Expand Down

0 comments on commit 5cb3564

Please sign in to comment.