From 50fbfe4d635b976c436d50e0735fd05358278357 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Mon, 28 Oct 2013 11:01:17 +0100 Subject: [PATCH] Filesystem/autoload fixes for windows, refs #2304, #2342, #2365 --- src/Composer/Autoload/AutoloadGenerator.php | 2 +- src/Composer/Util/Filesystem.php | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Composer/Autoload/AutoloadGenerator.php b/src/Composer/Autoload/AutoloadGenerator.php index b19548460..1252371d6 100644 --- a/src/Composer/Autoload/AutoloadGenerator.php +++ b/src/Composer/Autoload/AutoloadGenerator.php @@ -43,7 +43,7 @@ class AutoloadGenerator $filesystem = new Filesystem(); $filesystem->ensureDirectoryExists($config->get('vendor-dir')); - $basePath = $filesystem->normalizePath(getcwd()); + $basePath = $filesystem->normalizePath(realpath(getcwd())); $vendorPath = $filesystem->normalizePath(realpath($config->get('vendor-dir'))); $useGlobalIncludePath = (bool) $config->get('use-include-path'); $prependAutoloader = $config->get('prepend-autoloader') === false ? 'false' : 'true'; diff --git a/src/Composer/Util/Filesystem.php b/src/Composer/Util/Filesystem.php index 15ce1cebd..2e18eb71e 100644 --- a/src/Composer/Util/Filesystem.php +++ b/src/Composer/Util/Filesystem.php @@ -223,11 +223,11 @@ class Filesystem } $commonPath = $to; - while (strpos($from.'/', $commonPath.'/') !== 0 && '/' !== $commonPath && !preg_match('{^[a-z]:/?$}i', $commonPath) && '\\' !== $commonPath) { - $commonPath = dirname($commonPath); + while (strpos($from.'/', $commonPath.'/') !== 0 && '/' !== $commonPath && !preg_match('{^[a-z]:/?$}i', $commonPath)) { + $commonPath = strtr(dirname($commonPath), '\\', '/'); } - if (0 !== strpos($from, $commonPath) || '/' === $commonPath || '\\' === $commonPath) { + if (0 !== strpos($from, $commonPath) || '/' === $commonPath) { return $to; } @@ -262,7 +262,7 @@ class Filesystem $commonPath = $to; while (strpos($from.'/', $commonPath.'/') !== 0 && '/' !== $commonPath && !preg_match('{^[a-z]:/?$}i', $commonPath) && '.' !== $commonPath) { - $commonPath = dirname($commonPath); + $commonPath = strtr(dirname($commonPath), '\\', '/'); } if (0 !== strpos($from, $commonPath) || '/' === $commonPath || '.' === $commonPath) {