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

Breadcrumb

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

function Filesystem::size

Returns size of a file or directory specified by path. If a directory is given, its size will be computed recursively.

Parameters

string $path Path to the file or directory:

Return value

int

Throws

\RuntimeException

File

vendor/composer/composer/src/Composer/Util/Filesystem.php, line 578

Class

Filesystem
@author Jordi Boggiano <j.boggiano@seld.be> @author Johannes M. Schmitt <schmittjoh@gmail.com>

Namespace

Composer\Util

Code

public function size(string $path) {
    if (!file_exists($path)) {
        throw new \RuntimeException("{$path} does not exist.");
    }
    if (is_dir($path)) {
        return $this->directorySize($path);
    }
    return (int) filesize($path);
}

API Navigation

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