本文整理汇总了PHP中vfsStream::umask方法的典型用法代码示例。如果您正苦于以下问题:PHP vfsStream::umask方法的具体用法?PHP vfsStream::umask怎么用?PHP vfsStream::umask使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vfsStream
的用法示例。
在下文中一共展示了vfsStream::umask方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* constructor
*
* @param string $name
* @param int $permissions optional
*/
public function __construct($name, $permissions = null)
{
$this->name = $name;
$time = time();
if (null === $permissions) {
$permissions = $this->getDefaultPermissions() & ~vfsStream::umask();
}
$this->lastAccessed = $time;
$this->lastAttributeModified = $time;
$this->lastModified = $time;
$this->permissions = $permissions;
$this->user = vfsStream::getCurrentUser();
$this->group = vfsStream::getCurrentGroup();
}
示例2: mkdir
/**
* creates a new directory
*
* @param string $path
* @param int $mode
* @param int $options
* @return bool
*/
public function mkdir($path, $mode, $options)
{
$umask = vfsStream::umask();
if (0 < $umask) {
$permissions = $mode & ~$umask;
} else {
$permissions = $mode;
}
$path = $this->resolvePath(vfsStream::path($path));
if (null !== $this->getContent($path)) {
trigger_error('mkdir(): Path vfs://' . $path . ' exists', E_USER_WARNING);
return false;
}
if (null === self::$root) {
self::$root = vfsStream::newDirectory($path, $permissions);
return true;
}
$maxDepth = count(explode('/', $path));
$names = $this->splitPath($path);
$newDirs = $names['basename'];
$dir = null;
$i = 0;
while ($dir === null && $i < $maxDepth) {
$dir = $this->getContent($names['dirname']);
$names = $this->splitPath($names['dirname']);
if (null == $dir) {
$newDirs = $names['basename'] . '/' . $newDirs;
}
$i++;
}
if (null === $dir || $dir->getType() !== vfsStreamContent::TYPE_DIR || $dir->isWritable(vfsStream::getCurrentUser(), vfsStream::getCurrentGroup()) === false) {
return false;
}
$recursive = (STREAM_MKDIR_RECURSIVE & $options) !== 0 ? true : false;
if (strpos($newDirs, '/') !== false && false === $recursive) {
return false;
}
vfsStream::newDirectory($newDirs, $permissions)->at($dir);
return true;
}
示例3: umaskSettingShouldBeRespectedBySetup
/**
* @test
*/
public function umaskSettingShouldBeRespectedBySetup()
{
vfsStream::umask(022);
$root = vfsStream::setup();
$this->assertEquals(0755, $root->getPermissions());
}
示例4: umask
/**
* sets new umask setting and returns previous umask setting
*
* If no value is given only the current umask setting is returned.
*
* @param int $umask optional
* @return int
* @since 0.8.0
*/
public static function umask($umask = null)
{
$oldUmask = self::$umask;
if (null !== $umask) {
self::$umask = $umask;
}
return $oldUmask;
}