WP_Filesystem_Direct::chgrp()publicWP 2.5.0

Changes the file group.

Method of the class: WP_Filesystem_Direct{}

No Hooks.

Return

true|false. True on success, false on failure.

Usage

$WP_Filesystem_Direct = new WP_Filesystem_Direct();
$WP_Filesystem_Direct->chgrp( $file, $group, $recursive );
$file(string) (required)
Path to the file.
$group(string|int) (required)
A group name or number.
$recursive(true|false)
If set to true, changes file group recursively.
Default: false

Changelog

Since 2.5.0 Introduced.

WP_Filesystem_Direct::chgrp() code WP 6.6.2

public function chgrp( $file, $group, $recursive = false ) {
	if ( ! $this->exists( $file ) ) {
		return false;
	}

	if ( ! $recursive ) {
		return chgrp( $file, $group );
	}

	if ( ! $this->is_dir( $file ) ) {
		return chgrp( $file, $group );
	}

	// Is a directory, and we want recursive.
	$file     = trailingslashit( $file );
	$filelist = $this->dirlist( $file );

	foreach ( $filelist as $filename ) {
		$this->chgrp( $file . $filename, $group, $recursive );
	}

	return true;
}