Changes file or directory group

@param string $filename Path to the file or directory.
@param int $group A group number.
@param bool $recursive Apply to all files and directories within dirctory.
@access public
@return bool
344399
public function chgrp( $filename, $group, $recursive = false )
    {
        return $this->SFTPObject->chgrp($filename, $group, $recursive);
	}
690090
public function setInverted($recursive=true) {
		if($recursive===true){
			$content=$this->_self->getContent();
			if($content instanceof HtmlSemDoubleElement)
				$content->setInverted($recursive);
			elseif(\is_array($content) || $content instanceof \Traversable){
				foreach ($content as $elm){
					if($elm instanceof  HtmlSemDoubleElement){
						$elm->setInverted($recursive);
					}
				}
			}
		}
		return $this->_self->addToProperty("class", "inverted");
	}
492147
protected function listFiles($disk, $directory = '', $recursive = true)
    {
        if ($recursive) {
            return $this->filesystem->disk($disk)->allFiles($directory);
        } else {
            return $this->filesystem->disk($disk)->files($directory);
        }
    }
570849
public static function getUsersByGroup($groupId, $recursive = false)
	{
		$test = $recursive ? '>=' : '=';

		// First find the users contained in the group
		$db = App::get('db');
		$query = $db->getQuery()
			->select('DISTINCT(user_id)')
			->from('#__usergroups', 'ug1')
			->joinRaw('#__usergroups AS ug2', 'ug2.lft' . $test . 'ug1.lft AND ug1.rgt' . $test . 'ug2.rgt', 'inner')
			->join('#__user_usergroup_map AS m', 'm.group_id', 'ug2.id', 'inner')
			->whereEquals('ug1.id', $groupId);

		$db->setQuery($query->toString());

		$result = $db->loadColumn();

		// Clean up any NULL values, just in case
		Arr::toInteger($result);

		return $result;
	}
258957
public function getGroupNames($recursive = false)
    {
        $fields = [$this->schema->commonName(), $this->schema->memberOf()];

        $names = $this->getGroups($fields, $recursive)->map(function (Group $group) {
            return $group->getCommonName();
        })->toArray();

        return array_unique($names);
    }
113029
public function clearGroup($group)
    {
        $this->_File = null;

        $prefix = (string)$this->_config['prefix'];

        $directoryIterator = new RecursiveDirectoryIterator($this->_config['path']);
        $contents = new RecursiveIteratorIterator(
            $directoryIterator,
            RecursiveIteratorIterator::CHILD_FIRST
        );
        $filtered = new CallbackFilterIterator(
            $contents,
            function (SplFileInfo $current) use ($group, $prefix) {
                if (!$current->isFile()) {
                    return false;
                }

                $hasPrefix = $prefix === ''
                    || strpos($current->getBasename(), $prefix) === 0;
                if ($hasPrefix === false) {
                    return false;
                }

                $pos = strpos(
                    $current->getPathname(),
                    DIRECTORY_SEPARATOR . $group . DIRECTORY_SEPARATOR
                );

                return $pos !== false;
            }
        );
        foreach ($filtered as $object) {
            $path = $object->getPathname();
            $object = null;
            // @codingStandardsIgnoreLine
            @unlink($path);
        }

        return true;
    }
963637
public function groups($computerName, $recursive = null)
    {
        if ($recursive === null) {
            $recursive = $this->adldap->getRecursiveGroups();
        }

        $info = $this->find($computerName);

        if (is_array($info) && array_key_exists('memberof', $info)) {
            $groups = $this->adldap->utilities()->niceNames($info['memberof']);

            if ($recursive === true) {
                foreach ($groups as $id => $groupName) {
                    $extraGroups = $this->adldap->group()->recursiveGroups($groupName);

                    $groups = array_merge($groups, $extraGroups);
                }
            }

            return $groups;
        }

        return false;
    }
1166213
function recursive_groups($group, $cache_only = FALSE) {
        $this->_debug_message = "";
        $this->_warning_message = "";
        if ($group==NULL){ return (false); }

        $ret_groups=array();
        $ret_data = FALSE;

/*
    echo "DEBUG GROUP is group $group in cache ?\n";
    print_r($this->_cache_recursive_groups);
*/

        clearstatcache();
        
		if ($this->_cache_support) {
            if ("" != $this->get_cache_folder()) {
                if (file_exists($this->get_cache_folder()."ldap_rgroup_".md5($group).".cache")) {
                    if ((filemtime($this->get_cache_folder()."ldap_rgroup_".md5($group).".cache") + $this->get_cache_timeout()) > time()) {
                        if ($cache_handle = fopen($this->get_cache_folder()."ldap_rgroup_".md5($group).".cache", "rb")) {
                            $ret_groups = unserialize(fgets($cache_handle));
                            $ret_data = TRUE;
                            fclose($cache_handle);
                            @touch($this->get_cache_folder()."ldap_rgroup_".md5($group).".cache");
                        }
                    }
                }
            } elseif (isset($this->_cache_recursive_groups[$group])) {
                $ret_groups = $this->_cache_recursive_groups[$group];
                $ret_data = TRUE;
            }
        }

    	if (!$ret_data) {
            if (!$cache_only) {
    			$groups=$this->group_info($group,array($this->_group_attribute));
    			
    			// Additional test by SysCo/al
    			if (isset($groups[0][$this->_group_attribute]))
    			{
    				$groups=$groups[0][$this->_group_attribute];

    				if ($groups){
    					$group_names=$this->nice_names($groups);

    					$ret_groups=array_merge($ret_groups,$group_names); //final groups to return
    					
    					foreach ($group_names as $id => $group_name){
    						$child_groups=$this->recursive_groups($group_name);
    						$ret_groups=array_merge($ret_groups,$child_groups);
    					}
    				}
    			}
    			if ($this->_cache_support) {
                    if ("" != $this->get_cache_folder()) {
                        if (file_exists($this->get_cache_folder())) {
                            if ($cache_handle = fopen($this->get_cache_folder()."ldap_rgroup_".md5($group).".cache", "wb")) {
                                fwrite($cache_handle, serialize($ret_groups));
                                fclose($cache_handle);
                                @chmod($this->get_cache_folder()."ldap_rgroup_".md5($group).".cache", octdec($this->_linux_file_mode));
                            }
                        }
                    } else {
        				$this->_cache_recursive_groups[$group] = $ret_groups;
                    }
    			}
            } else {
                $this->_debug_message = "The requested group $group is not in cache.";
            }
        }
        return ($ret_groups);
    }
651660
public function setFilename($filename)
    {
        $filename = $this->filterFilename($filename);

        // Check existing folder path
        $folder = '';
        $parent = $this->Parent();
        if ($parent && $parent->exists()) {
            $folder = $parent->getFilename();
        }

        // Detect change in foldername
        $newFolder = ltrim(dirname(trim($filename, '/')), '.');
        if ($folder !== $newFolder) {
            if (!$newFolder) {
                $this->ParentID = 0;
            } else {
                $parent = Folder::find_or_make($newFolder);
                $this->ParentID = $parent->ID;
            }
        }

        // Update base name
        $this->Name = basename($filename);
        return $this;
    }
1257906
protected function changePermission(string $path, $mode = 0755, bool $recursively = false): void
    {
        $filesystem = $this->getContainer()['files'];

        $filesystem->chmod($path, $mode);

        if ($recursively === false) {
            return;
        }

        $lists = $filesystem->allFiles($path);

        $ignoredPath = function ($dir) {
            return (\substr($dir, -3) === '/..' || \substr($dir, -2) === '/.');
        };

        // this is to check if return value is just a single file,
        // avoiding infinite loop when we reach a file.
        if ($lists !== [$path]) {
            foreach ($lists as $dir) {
                // Not a file or folder, ignore it.
                if (! $ignoredPath($dir)) {
                    $this->changePermission($dir, $mode, true);
                }
            }
        }
    }
1120042
private function chgrp(string $path, int $group): bool
    {
        if (!@chgrp($path, $group)) {
            $message = 'Could not change file group.';
            if ($error = error_get_last()) {
                $message .= sprintf(' Errno: %d; %s', $error['type'], $error['message']);
            }
            throw new FileException($message);
        }

        return true;
    }
144841
public function changeOwner( $userName, $recursive = FALSE )
	{
		if( !$userName )
			throw new InvalidArgumentException( 'User missing' );
		$number	= (int) chown( $this->folderName, $userName );

		if( !$recursive )
			return $number;
		$iterator = new RecursiveIteratorIterator(
			new RecursiveDirectoryIterator( $this->folderName ),
			RecursiveIteratorIterator::SELF_FIRST
		);
		foreach( $iterator as $item )
			$number += (int) chown( $item, $userName );
		return $number;
	}
1295904
protected function doListContents($directory, $recursive)
	{
		$filter = function ($path) use ($directory, $recursive) {
			// Remove the root directory from any listing.
			if ($path === '') {
				return false;
			}

			if (Util::dirname($path) === $directory) {
				return true;
			}

			return $recursive && $this->pathIsInDirectory($path, $directory);
		};

		return \array_filter(\array_keys($this->storage), $filter);
	}
1269625
function user_groups($username,$recursive=NULL){
        if ($username==NULL){ return (false); }
        if ($recursive==NULL){ $recursive=$this->_recursive_groups; } //use the default option if they haven't set it
        if (!$this->_bind){ return (false); }
        
        //search the directory for their information
        $info=@$this->user_info($username,array($this->_group_attribute,"member","primarygroupid"));
        
        $groups=$this->nice_names($info[0][$this->_group_attribute]); //presuming the entry returned is our guy (unique usernames)

        if ($recursive){
            foreach ($groups as $id => $group_name){
                $extra_groups=$this->recursive_groups($group_name);
                $groups=array_merge($groups,$extra_groups);
            }
        }
        return ($groups);
    }
679114
public function process($recursive = false)
		{
			// reset
			$this->folders      = [];
			$this->controllers  = [];
			
			// variables
			$files = array_diff(scandir($this->path), ['.', '..']);

			// loop
			foreach ($files as $file)
			{
				$path = $this->path . $file;
				if(is_dir($path))
				{
					$this->folders[] = new Folder($path, $recursive);
				}
				else if(is_file($path) && preg_match('/Controller.php$/', $path))
				{
					$this->controllers[] = new Controller($path);
				}
			}
		}
1286609
public function replace($items = array(), $recursive = true)
	{
		$items = (array) $items;

		if ($recursive) {
			$this->data = array_replace_recursive($this->data, $items);
		} else {
			$this->data = $items;
		}
	}
410450
static public function rmdir($dir, $recursive = false)
    {
        $dir = realpath($dir);
        if (!is_dir($dir)) return true;
        if (true !== $recursive) return @rmdir($dir);
        $dp = @opendir($dir);
        while ($file = @readdir($dp)) {
            if ('.' === $file || '..' === $file) continue;
            $cur_file = $dir . '/' . $file;
            if (is_dir($cur_file)) {
                self::rmdir($cur_file, true);
            } elseif (is_file($cur_file)) {
                @unlink($cur_file);
            }
        }
        @closedir($dp);
        return @rmdir($dir);
    }