. */ require_once 'phing/tasks/system/condition/ConditionBase.php'; /** * Condition that tests the OS type. * * @author Andreas Aderhold * @copyright © 2001,2002 THYRELL. All rights reserved * @version $Revision: 905 $ $Date: 2010-10-05 18:28:03 +0200 (Tue, 05 Oct 2010) $ * @access public * @package phing.tasks.system.condition */ class OsCondition implements Condition { private $family; function setFamily($f) { $this->family = strtolower($f); } function evaluate() { $osName = strtolower(Phing::getProperty("os.name")); if ($this->family !== null) { if ($this->family === "windows") { return StringHelper::startsWith("win", $osName); } elseif ($this->family === "mac") { return (strpos($osName, "mac") !== false || strpos($osName, "darwin") !== false); } elseif ($this->family === ("unix")) { return ( StringHelper::endsWith("ix", $osName) || StringHelper::endsWith("ux", $osName) || StringHelper::endsWith("bsd", $osName) || StringHelper::startsWith("sunos", $osName) || StringHelper::startsWith("darwin", $osName) ); } throw new BuildException("Don't know how to detect os family '" . $this->family . "'"); } return false; } }