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

Breadcrumb

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

function Comparer::doTree

Parameters

mixed[] $array:

Return value

array<string, array<string, string|false>>|false

1 call to Comparer::doTree()
Comparer::doCompare in vendor/composer/composer/src/Composer/Package/Comparer/Comparer.php

File

vendor/composer/composer/src/Composer/Package/Comparer/Comparer.php, line 124

Class

Comparer
class Comparer

Namespace

Composer\Package\Comparer

Code

private function doTree(string $dir, array &$array) {
    if ($dh = opendir($dir)) {
        while ($file = readdir($dh)) {
            if ($file !== '.' && $file !== '..') {
                if (is_link($dir . '/' . $file)) {
                    $array[$dir][$file] = readlink($dir . '/' . $file);
                }
                elseif (is_dir($dir . '/' . $file)) {
                    if (!count($array)) {
                        $array[0] = 'Temp';
                    }
                    if (!$this->doTree($dir . '/' . $file, $array)) {
                        return false;
                    }
                }
                elseif (is_file($dir . '/' . $file) && filesize($dir . '/' . $file)) {
                    $array[$dir][$file] = hash_file(\PHP_VERSION_ID > 80100 ? 'xxh3' : 'sha1', $dir . '/' . $file);
                }
            }
        }
        if (count($array) > 1 && isset($array['0'])) {
            unset($array['0']);
        }
        return $array;
    }
    return false;
}
RSS feed
Powered by Drupal