12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <?php
- require_once 'phing/tasks/system/condition/ConditionBase.php';
- 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;
- }
- }
|