Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Filesystem.php

function Filesystem::chgrp

Change the group of an array of files or directories.

This method always throws on Windows, as the underlying PHP function is not supported.

Parameters

string|int $group A group name or number:

bool $recursive Whether change the group recursively or not:

Throws

IOException When the change fails

See also

https://www.php.net/chgrp

File

vendor/symfony/filesystem/Filesystem.php, line 265

Class

Filesystem
Provides basic utility to manipulate the file system.

Namespace

Symfony\Component\Filesystem

Code

public function chgrp(string|iterable $files, string|int $group, bool $recursive = false) : void {
    foreach ($this->toIterable($files) as $file) {
        if ($recursive && is_dir($file) && !is_link($file)) {
            $this->chgrp(new \FilesystemIterator($file), $group, true);
        }
        if (is_link($file) && \function_exists('lchgrp')) {
            if (!self::box('lchgrp', $file, $group)) {
                throw new IOException(\sprintf('Failed to chgrp file "%s": ', $file) . self::$lastError, 0, null, $file);
            }
        }
        else {
            if (!self::box('chgrp', $file, $group)) {
                throw new IOException(\sprintf('Failed to chgrp file "%s": ', $file) . self::$lastError, 0, null, $file);
            }
        }
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal