use value of DIRECTORY_SEPARATOR to detect Windows

This commit unifies the detection of Windows builds across the Symfony
codebase.
This commit is contained in:
Christian Flothmann 2014-12-29 13:15:05 +01:00
parent 563f9476df
commit f38a72a2fb
5 changed files with 7 additions and 7 deletions

View File

@ -84,7 +84,7 @@ EOT;
EOT; EOT;
$errorMessage = 'An error occurred'; $errorMessage = 'An error occurred';
if (defined('PHP_WINDOWS_VERSION_BUILD')) { if ('\\' === DIRECTORY_SEPARATOR) {
$successOutputProcessDebug = str_replace("'", '"', $successOutputProcessDebug); $successOutputProcessDebug = str_replace("'", '"', $successOutputProcessDebug);
} }

View File

@ -286,7 +286,7 @@ class Filesystem
*/ */
public function symlink($originDir, $targetDir, $copyOnWindows = false) public function symlink($originDir, $targetDir, $copyOnWindows = false)
{ {
if (defined('PHP_WINDOWS_VERSION_MAJOR') && $copyOnWindows) { if ('\\' === DIRECTORY_SEPARATOR && $copyOnWindows) {
$this->mirror($originDir, $targetDir); $this->mirror($originDir, $targetDir);
return; return;

View File

@ -59,7 +59,7 @@ class FilesystemTest extends FilesystemTestCase
public function testCopyUnreadableFileFails() public function testCopyUnreadableFileFails()
{ {
// skip test on Windows; PHP can't easily set file as unreadable on Windows // skip test on Windows; PHP can't easily set file as unreadable on Windows
if (defined('PHP_WINDOWS_VERSION_MAJOR')) { if ('\\' === DIRECTORY_SEPARATOR) {
$this->markTestSkipped('This test cannot run on Windows.'); $this->markTestSkipped('This test cannot run on Windows.');
} }
@ -133,7 +133,7 @@ class FilesystemTest extends FilesystemTestCase
public function testCopyWithOverrideWithReadOnlyTargetFails() public function testCopyWithOverrideWithReadOnlyTargetFails()
{ {
// skip test on Windows; PHP can't easily set file as unwritable on Windows // skip test on Windows; PHP can't easily set file as unwritable on Windows
if (defined('PHP_WINDOWS_VERSION_MAJOR')) { if ('\\' === DIRECTORY_SEPARATOR) {
$this->markTestSkipped('This test cannot run on Windows.'); $this->markTestSkipped('This test cannot run on Windows.');
} }

View File

@ -1249,7 +1249,7 @@ class Process
*/ */
private function getDescriptors() private function getDescriptors()
{ {
if (defined('PHP_WINDOWS_VERSION_BUILD')) { if ('\\' === DIRECTORY_SEPARATOR) {
$this->processPipes = WindowsPipes::create($this, $this->input); $this->processPipes = WindowsPipes::create($this, $this->input);
} else { } else {
$this->processPipes = UnixPipes::create($this, $this->input); $this->processPipes = UnixPipes::create($this, $this->input);

View File

@ -52,7 +52,7 @@ class CliDumper extends AbstractDumper
{ {
parent::__construct($output); parent::__construct($output);
if (defined('PHP_WINDOWS_VERSION_MAJOR') && false !== @getenv('ANSICON')) { if ('\\' === DIRECTORY_SEPARATOR && false !== @getenv('ANSICON')) {
// Use only the base 16 xterm colors when using ANSICON // Use only the base 16 xterm colors when using ANSICON
$this->setStyles(array( $this->setStyles(array(
'default' => '31', 'default' => '31',
@ -394,7 +394,7 @@ class CliDumper extends AbstractDumper
} }
} }
if (defined('PHP_WINDOWS_VERSION_MAJOR')) { if ('\\' === DIRECTORY_SEPARATOR) {
static::$defaultColors = @(false !== getenv('ANSICON') || 'ON' === getenv('ConEmuANSI')); static::$defaultColors = @(false !== getenv('ANSICON') || 'ON' === getenv('ConEmuANSI'));
} elseif (function_exists('posix_isatty')) { } elseif (function_exists('posix_isatty')) {
$h = stream_get_meta_data($this->outputStream) + array('wrapper_type' => null); $h = stream_get_meta_data($this->outputStream) + array('wrapper_type' => null);