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

Breadcrumb

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

function Filesystem::chmod

Same name in this branch
  1. 11.1.x core/lib/Drupal/Core/File/FileSystem.php \Drupal\Core\File\FileSystem::chmod()

Change mode for an array of files or directories.

Parameters

int $mode The new mode (octal):

int $umask The mode mask (octal):

bool $recursive Whether change the mod recursively or not:

Throws

IOException When the change fails

File

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

Class

Filesystem
Provides basic utility to manipulate the file system.

Namespace

Symfony\Component\Filesystem

Code

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

API Navigation

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