本文整理匯總了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;
}