本文整理匯總了PHP中Sys::isWin方法的典型用法代碼示例。如果您正苦於以下問題:PHP Sys::isWin方法的具體用法?PHP Sys::isWin怎麽用?PHP Sys::isWin使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Sys
的用法示例。
在下文中一共展示了Sys::isWin方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: _setPerms
/**
* @param string $filename
* @param bool $isFlag
* @param int $perm
* @return bool
*/
protected static function _setPerms($filename, $isFlag, $perm)
{
$stat = @stat($filename);
if ($stat === false) {
return false;
}
// We're on Windows
if (Sys::isWin()) {
//@codeCoverageIgnoreStart
return true;
//@codeCoverageIgnoreEnd
}
list($myuid, $mygid) = array(posix_geteuid(), posix_getgid());
$isMyUid = $stat['uid'] == $myuid;
$isMyGid = $stat['gid'] == $mygid;
//@codeCoverageIgnoreStart
if ($isFlag) {
// Set only the user writable bit (file is owned by us)
if ($isMyUid) {
return chmod($filename, fileperms($filename) | intval('0' . $perm . '00', 8));
}
// Set only the group writable bit (file group is the same as us)
if ($isMyGid) {
return chmod($filename, fileperms($filename) | intval('0' . $perm . $perm . '0', 8));
}
// Set the world writable bit (file isn't owned or grouped by us)
return chmod($filename, fileperms($filename) | intval('0' . $perm . $perm . $perm, 8));
} else {
// Set only the user writable bit (file is owned by us)
if ($isMyUid) {
$add = intval('0' . $perm . $perm . $perm, 8);
return self::_chmod($filename, $perm, $add);
}
// Set only the group writable bit (file group is the same as us)
if ($isMyGid) {
$add = intval('00' . $perm . $perm, 8);
return self::_chmod($filename, $perm, $add);
}
// Set the world writable bit (file isn't owned or grouped by us)
$add = intval('000' . $perm, 8);
return self::_chmod($filename, $perm, $add);
}
//@codeCoverageIgnoreEnd
}