Change owner permission

@param string $path
@param int | string $user
@param bool $recurse

@return bool
341534
public function chown($path, $user = '', $recurse = false)
    {
        if (!file_exists($path)) {
            return false;
        }

        if (empty($user)) {
            $user = $this->getDefaultOwner();
        }

        //Set chown for non-recursive request
        if (!$recurse) {
            return $this->chownReal($path, $user);
        }

        //Recursive chown
        return $this->chownRecurse($path, $user);
    }
366212
public function getResourceUserEvaluation(Path $path, User $user)
    {
        return $this->resourceEvalManager->getResourceUserEvaluation($path->getResourceNode(), $user);
    }
536353
public function grantAccessByPermissions($permissions, UserInterface $user = null)
    {
        $user = $user ? : $this->currentUser;
        return count(array_diff($permissions, $this->gatherPermissions($user))) === 0;
    }
1134398
public function mkdir($path, $mode, $options)
    {
        $container = $this->getContainerFromContext($path);
        $path = $this->stripScheme($path);
        $recursive = (bool) ($options & STREAM_MKDIR_RECURSIVE);

        try {
            //need to check all parents for permissions
            $parentPath = $path;
            while ($parentPath = dirname($parentPath)) {
                try {
                    $parent = $container->nodeAt($parentPath);
                    $permissionHelper = $container->getPermissionHelper($parent);
                    if (!$permissionHelper->isWritable()) {
                        trigger_error(sprintf('mkdir: %s: Permission denied', dirname($path)), E_USER_WARNING);

                        return false;
                    }
                    if ($parent instanceof Root) {
                        break;
                    }
                } catch (NotFoundException $e) {
                    break; //will sort missing parent below
                }
            }
            $container->createDir($path, $recursive, $mode);
        } catch (FileExistsException $e) {
            trigger_error($e->getMessage(), E_USER_WARNING);

            return false;
        } catch (NotFoundException $e) {
            trigger_error(sprintf('mkdir: %s: No such file or directory', dirname($path)), E_USER_WARNING);

            return false;
        }

        return true;
    }
1118376
function mkdir($path, $owner = null, $mode = 0755)
    {
        mkdir($path, $mode, true);

        if ($owner) {
            $this->chown($path, $owner);
        }
    }
348528
final public function permissions(bool $recheck = false): Privileges
    {
        if (!$this->privileges || $recheck) {
            $this->privileges = new Privileges($this->path);
        }

        return $this->privileges;
    }
39519
public function chmod( $path, $mode, $recursive = false )
    {
        return $this->SFTPObject->chmod($mode, $path, $recursive);
	}
360792
public static function chownPath($path, $user = null, $recursive = true)
    {
        $path = realpath($path);
        if (empty($path)) {
            return false;
        }

        if (empty($user)) {
            $user = self::getDefaultUser();
        }
        self::chown($path, $user, $recursive);
        return true;
    }
746752
def set_permission(self, path, **kwargs):
        
        response = self._put(path, 'SETPERMISSION', **kwargs)
        assert not response.content
2116
public void setOwner(String src, String username, String group
  ) throws IOException {
    INode[] inodes = null;
    writeLock();
    try {
      if (isInSafeMode()) {
        throw new SafeModeException("Cannot set permission for " + src, safeMode);
      }
      inodes = dir.getExistingPathINodes(src);
      if (isPermissionCheckingEnabled(inodes)) {
        FSPermissionChecker pc = checkOwner(src, inodes);
        if (!pc.isSuper) {
          if (username != null && !pc.user.equals(username)) {
            if (this.permissionAuditOnly) {
              // do not throw the exception, we would like to only log.
              LOG.warn("PermissionAudit failed on " + src + 
                  ": non-super user cannot change owner.");
            } else {
              throw new AccessControlException("Non-super user cannot change owner.");
            }
          }
          if (group != null && !pc.containsGroup(group)) {
            if (this.permissionAuditOnly) {
              // do not throw the exception, we would like to only log.
              LOG.warn("PermissionAudit failed on " + src + 
                  ": user does not belong to " + group + " .");
            } else {
              throw new AccessControlException("User does not belong to " + group
                  + " .");
            }
          }
        }
      }
      dir.setOwner(src, username, group);
    } finally {
      writeUnlock();
    }
    getEditLog().logSync(false);
    if (auditLog.isInfoEnabled()) {
      logAuditEvent(getCurrentUGI(),
        Server.getRemoteIp(),
        "setOwner", src, null, getLastINode(inodes));
    }
  }
1116195
static function changeFilePermissions( $filepath )
    {
        if ( !file_exists( $filepath ) )
            return false;
        $ini = eZINI::instance( 'image.ini' );
        $perm = $ini->variable( "FileSettings", "ImagePermissions" );
        $success = false;
        $oldmask = umask( 0 );
        if ( !chmod( $filepath, octdec( $perm ) ) )
            eZDebug::writeError( "Chmod $perm $filepath failed", __METHOD__ );
        else
            $success = true;
        umask( $oldmask );
        return $success;
    }
219157
protected function setGeneratedFilePermissions($strFilePath)
    {
        // CHMOD to full read/write permissions (applicable only to nonwindows)
        // Need to ignore error handling for this call just in case
        if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') {
            $e = new Error\Handler();
            chmod($strFilePath, 0666);
        }
    }
814103
public function mkdir($path, $permissions = 0755)
    {
        $writeBinn = new BinnList;

        $writeBinn->addUint8(self::FSERV_MKDIR);
        $writeBinn->addStr($path);
        $writeBinn->addStr($permissions);

        $read = $this->writeAndReadSocket($writeBinn->serialize());

        $readBinn = new BinnList;
        $readBinn->binnOpen($read);
        $results = $readBinn->unserialize();

        if ($results[0] != self::FSERV_STATUS_OK) {
            throw new RuntimeException('Couldn\'t make directory: ' . isset($results[1]) ? $results[1] : 'Unknown');
        }

        return true;
    }
1338078
public function mkdir(string $path, int $mode, int $options): bool
    {
        $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;
    }
419192
public function delete($path, $recursive = false)
    {
        if ($path instanceof FileInfoInterface) {
            $path = $path->getRelativePath();
        }

        $info = $this->info($path);
        if (!$info->exists()) {
            return $this;
        }

        if (!$info->isDir()) {
            if (!unlink($info->getStreamUrl())) {
                throw new RuntimeException(sprintf(
                    'Failed to delete file "%s": %s',
                    $path, $this->getLastPhpError()
                ));
            }

            return $this;
        }

        if ($recursive) {
            $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($info->getStreamUrl()), RecursiveIteratorIterator::CHILD_FIRST);

            /* @var $child FileInfoInterface */
            foreach ($iterator as $child) {
                if ($child->isDir()) {
                    $result = @rmdir($child->getStreamUrl());
                } else {
                    $result = @unlink($child->getStreamUrl());
                }

                if (!$result) {
                    throw new RuntimeException(sprintf(
                        'Failed to remove entry "%s": %s',
                        $child->getRelativePath(), $this->getLastPhpError()
                    ));
                }
            }
        }

        if (!rmdir($info->getStreamUrl())) {
            throw new RuntimeException(sprintf(
                'Failed to remove directory "%s": %s',
                $path, $this->getLastPhpError()
            ));
        }

        return $this;
    }
589493
public static void setPermissions(Path location, Optional<String> owner, Optional<String> group, FileSystem fs,
      FsPermission permission) {
    try {
      if (!owner.isPresent()) {
        return;
      }
      if (!group.isPresent()) {
        return;
      }
      fs.setOwner(location, owner.get(), group.get());
      fs.setPermission(location, permission);
      if (!fs.isDirectory(location)) {
        return;
      }
      for (FileStatus fileStatus : fs.listStatus(location)) {
        setPermissions(fileStatus.getPath(), owner, group, fs, permission);
      }
    } catch (IOException e) {
      log.warn("Exception occurred while trying to change permissions : " + e.getMessage());
    }
  }
362236
public function mkdir($path, $permissions = null)
	{
		if ( ! $this->_is_conn())
		{
			return false;
		}

		$result = ftp_mkdir($this->_conn_id, $path);

		if ($result === false)
		{
			if ($this->_debug == true)
			{
				throw new \FtpFileAccessException('Unable to create directory');
			}
			return false;
		}

		// Set file permissions if needed
		if ($permissions !== null)
		{
			$this->chmod($path, (int) $permissions);
		}

		return true;
	}