Skip to content
This repository
Browse code

fixes #6467, cake bake on windows drive. thanks burzum

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8257 3807eeeb-6ff5-0310-8944-8be069107fe0
  • Loading branch information...
commit f53181bc967ef4c9e7c46f3a2eade9e48ae6ad56 1 parent a6f25f5
authored July 27, 2009
14  cake/console/cake.php
@@ -446,13 +446,15 @@ function stderr($string) {
446 446
  */
447 447
 	function parseParams($params) {
448 448
 		$this->__parseParams($params);
449  
-
450 449
 		$defaults = array('app' => 'app', 'root' => dirname(dirname(dirname(__FILE__))), 'working' => null, 'webroot' => 'webroot');
451  
-
452 450
 		$params = array_merge($defaults, array_intersect_key($this->params, $defaults));
453  
-
454  
-		$isWin = array_filter(array_map('strpos', $params, array('\\')));
455  
-
  451
+		$isWin = false;
  452
+		foreach ($defaults as $default => $value) {
  453
+			if (strpos($params[$default], '\\') !== false) {
  454
+				$isWin = true;
  455
+				break;
  456
+			}
  457
+		}
456 458
 		$params = str_replace('\\', '/', $params);
457 459
 
458 460
 		if (!empty($params['working']) && (!isset($this->args[0]) || isset($this->args[0]) && $this->args[0]{0} !== '.')) {
@@ -464,7 +466,7 @@ function parseParams($params) {
464 466
 			}
465 467
 		}
466 468
 
467  
-		if ($params['app'][0] == '/' || preg_match('/([a-zA-Z])(:)/i', $params['app'], $matches)) {
  469
+		if ($params['app'][0] == '/' || preg_match('/([a-z])(:)/i', $params['app'], $matches)) {
468 470
 			$params['root'] = dirname($params['app']);
469 471
 		} elseif (strpos($params['app'], '/')) {
470 472
 			$params['root'] .= '/' . dirname($params['app']);
19  cake/tests/cases/console/cake.test.php
@@ -396,6 +396,25 @@ function testParseParams() {
396 396
 		$Dispatcher->params = $Dispatcher->args = array();
397 397
 		$Dispatcher->parseParams($params);
398 398
 		$this->assertEqual($expected, $Dispatcher->params);
  399
+
  400
+
  401
+		$params = array(
  402
+			'cake.php',
  403
+			'-working',
  404
+			'D:\www',
  405
+			'bake',
  406
+			'my_app',
  407
+		);
  408
+		$expected = array(
  409
+			'working' => 'D:\www',
  410
+			'app' => 'www',
  411
+			'root' => 'D:',
  412
+			'webroot' => 'webroot'
  413
+		);
  414
+
  415
+		$Dispatcher->params = $Dispatcher->args = array();
  416
+		$Dispatcher->parseParams($params);
  417
+		$this->assertEqual($expected, $Dispatcher->params);
399 418
 	}
400 419
 /**
401 420
  * testBuildPaths method

0 notes on commit f53181b

Please sign in to comment.
Something went wrong with that request. Please try again.