Browse Source

Filesystem/autoload fixes for windows, refs #2304, #2342, #2365

Jordi Boggiano 11 years ago
parent
commit
50fbfe4d63
2 changed files with 5 additions and 5 deletions
  1. 1 1
      src/Composer/Autoload/AutoloadGenerator.php
  2. 4 4
      src/Composer/Util/Filesystem.php

+ 1 - 1
src/Composer/Autoload/AutoloadGenerator.php

@@ -43,7 +43,7 @@ class AutoloadGenerator
 
 
         $filesystem = new Filesystem();
         $filesystem = new Filesystem();
         $filesystem->ensureDirectoryExists($config->get('vendor-dir'));
         $filesystem->ensureDirectoryExists($config->get('vendor-dir'));
-        $basePath = $filesystem->normalizePath(getcwd());
+        $basePath = $filesystem->normalizePath(realpath(getcwd()));
         $vendorPath = $filesystem->normalizePath(realpath($config->get('vendor-dir')));
         $vendorPath = $filesystem->normalizePath(realpath($config->get('vendor-dir')));
         $useGlobalIncludePath = (bool) $config->get('use-include-path');
         $useGlobalIncludePath = (bool) $config->get('use-include-path');
         $prependAutoloader = $config->get('prepend-autoloader') === false ? 'false' : 'true';
         $prependAutoloader = $config->get('prepend-autoloader') === false ? 'false' : 'true';

+ 4 - 4
src/Composer/Util/Filesystem.php

@@ -223,11 +223,11 @@ class Filesystem
         }
         }
 
 
         $commonPath = $to;
         $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;
             return $to;
         }
         }
 
 
@@ -262,7 +262,7 @@ class Filesystem
 
 
         $commonPath = $to;
         $commonPath = $to;
         while (strpos($from.'/', $commonPath.'/') !== 0 && '/' !== $commonPath && !preg_match('{^[a-z]:/?$}i', $commonPath) && '.' !== $commonPath) {
         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) {
         if (0 !== strpos($from, $commonPath) || '/' === $commonPath || '.' === $commonPath) {