1
0
Fork 0

Fix archiving paths on windows

pull/5303/head
Jordi Boggiano 2016-05-10 14:40:46 +01:00
parent 046c2d64a5
commit 5cb3564672
1 changed files with 6 additions and 3 deletions

View File

@ -13,6 +13,7 @@
namespace Composer\Package\Archiver;
use ZipArchive;
use Composer\Util\Filesystem;
/**
* @author Jan Prieser <jan@prieser.net>
@ -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 {