Change group permission

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

@return bool
195263
public function chgrp($path, $group = null, $recurse = false)
    {
        if (!file_exists($path)) {
            return false;
        }

        if (!isset($group)) {
            $group = $this->getDefaultGroup();
        }

        //Set chgrp for non-recursive request
        if (!$recurse) {
            return $this->chgrpReal($path, $group);
        }

        //Recursive chown
        return $this->chgrpRecurse($path, $group);
    }
664710
protected function changeMode($path, $mode)
    {
        $oldPermission = substr(sprintf('%o', fileperms($path)), -4);
        $newPermission = sprintf('%04o', $mode);
        if ($oldPermission !== $newPermission) {
            if(!@chmod($path, $mode)) {
                throw new CException (sprintf("Unable to change mode for %s, permission denied", $path));
            }
            echo sprintf("Changing mode for %s (%s => %s)... ", $path, $oldPermission, $newPermission);
            echo "done\n";
        }
    }
581382
public function setGroup($group)
	{
	    if ($this->options['group']) {
	        $group = str_replace('//', '/', $this->options['group'] . '/' . $group);
	    }
	    
	    return $this->setOption('group', $group);
	}
1003572
public function setGroup(Group $group = null): FamilyPermission
    {
        $this->group = $group;
        if ($group && !$group->getFamilyPermissions()->contains($this)) {
            $group->getFamilyPermissions()->add($this);
        }

        return $this;
    }
20999
public function changeFolder(String $path) : Bool
    {
        if( ftp_chdir($this->connect, $path) )
        {
            return true;
        }
        else
        {
            throw new FolderChangeDirException(NULL, $path);
        }
    }
44190
public function setGroup($title, $path) {
		$path = rtrim(realpath($path), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
		
		$this->groups[(string) $title] = $path;
	}
1004976
public static function recursiveChmod($path, $mod = 0777)
    {
        $path = Normalize::diskFullPath($path);
        if (!self::exist($path)) {
            return;
        }

        $dir = new \DirectoryIterator($path);
        foreach ($dir as $item) {
            // change chmod for folders and files
            if ($item->isDir() || $item->isFile()) {
                chmod($item->getPathname(), 0777);
            }
            // try to recursive chmod folders
            if ($item->isDir() && !$item->isDot()) {
                self::recursiveChmod($item->getPathname(), $mod);
            }
        }
    }
1018721
public function changeGroup( $groupName, $recursive = FALSE )
	{
		if( !$groupName )
			throw new InvalidArgumentException( 'Group is missing' );
		$number	= (int) chgrp( $this->folderName, $groupName );

		if( !$recursive )
			return $number;
		$iterator = new RecursiveIteratorIterator(
			new RecursiveDirectoryIterator( $this->folderName ),
			RecursiveIteratorIterator::SELF_FIRST
		);
		foreach( $iterator as $item )
			$number += (int) chgrp( $item, $groupName );
		return $number;
	}
39519
public function chmod( $path, $mode, $recursive = false )
    {
        return $this->SFTPObject->chmod($mode, $path, $recursive);
	}
38735
public void changeGroup(String group, String file)
        throws IOException, ServerException {
        String arguments = group + " " + file;
        Command cmd = new Command("SITE CHGRP", arguments);
        try {
            controlChannel.execute(cmd);
        } catch (UnexpectedReplyCodeException urce) {
            throw ServerException.embedUnexpectedReplyCodeException(urce);
        } catch (FTPReplyParseException rpe) {
            throw ServerException.embedFTPReplyParseException(rpe);
        }
    }
829659
private function createDir($path, $chmod = 0777, $recursive = true)
    {
        if (!mkdir($path, $chmod, $recursive)) {
            throw new RuntimeException(
                sprintf(
                    'The directory path "%s" could not be created.',
                    $path
                )
            );
        }
    }
344399
public function chgrp( $filename, $group, $recursive = false )
    {
        return $this->SFTPObject->chgrp($filename, $group, $recursive);
	}
311545
public function addPath($path, $clearCache = true, $group = '__DEFAULT__')
	{
		//var_dump(func_get_args());
		$path = $this->normalizePath($path);

		// This is done for easy reference and
		// eliminates the need to check for doubles
		$this->paths[$group][$path] = $path;

		if ($clearCache)
		{
			$this->cache = [];
		}
	}
455706
@Override
  public void setPermission(Path p, FsPermission permission
      ) throws IOException {
    FsAction user = permission.getUserAction();
    FsAction group = permission.getGroupAction();
    FsAction other = permission.getOtherAction();
    
    File f = pathToFile(p);
    
    // Fork chmod if group and other permissions are different...
    if (group != other) {
      execSetPermission(f, permission);
      return;
    }
    
    boolean rv = true;
    
    // read perms
    rv = f.setReadable(group.implies(FsAction.READ), false);
    checkReturnValue(rv, p, permission);
    if (group.implies(FsAction.READ) != user.implies(FsAction.READ)) {
      f.setReadable(user.implies(FsAction.READ), true);
      checkReturnValue(rv, p, permission);
    }

    // write perms
    rv = f.setWritable(group.implies(FsAction.WRITE), false);
    checkReturnValue(rv, p, permission);
    if (group.implies(FsAction.WRITE) != user.implies(FsAction.WRITE)) {
      f.setWritable(user.implies(FsAction.WRITE), true);
      checkReturnValue(rv, p, permission);
    }

    // exec perms
    rv = f.setExecutable(group.implies(FsAction.EXECUTE), false);
    checkReturnValue(rv, p, permission);
    if (group.implies(FsAction.EXECUTE) != user.implies(FsAction.EXECUTE)) {
      f.setExecutable(user.implies(FsAction.EXECUTE), true);
      checkReturnValue(rv, p, permission);
    }
  }
1296999
public static function chmod($path, $mode = NULL)
    {
        if (!isset($mode)) {
            if (is_file($path)) {
                $mode = Constants::FILESYSTEM_FILE_PERMISSIONS_DEFAULT;
            } elseif (is_dir($path)) {
                $mode = Constants::FILESYSTEM_DIR_PERMISSIONS_DEFAULT;
            } else {
                return false;
            }
        }
        $umask = umask();
        $res = chmod($path, $mode);
        umask($umask);

        return $res;
    }
407682
public function removePath($path, $clearCache = true, $group = '__DEFAULT__')
	{
		$path = $this->normalizePath($path);

		if ($path and isset($this->paths[$group][$path]))
		{
			unset($this->paths[$group][$path]);

			if ($clearCache) $this->removePathCache($path);
		}
	}
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;
    }