You are here

function VirtualFilesystem::getStat in X Autoload 7.5

Same name and namespace in other branches
  1. 7.4 tests/lib/Filesystem/VirtualFilesystem.php \Drupal\xautoload\Tests\Filesystem\VirtualFilesystem::getStat()

Parameters

string $path:

bool $report:

Return value

array

File

tests/src/Filesystem/VirtualFilesystem.php, line 182

Class

VirtualFilesystem

Namespace

Drupal\xautoload\Tests\Filesystem

Code

function getStat($path, $report = TRUE) {
  if ($report) {
    $this->reportedOperations[] = $path . ' - stat';
  }
  if (!isset($this->knownPaths[$path])) {

    // File does not exist.
    return FALSE;
  }
  elseif (self::DIR === $this->knownPaths[$path]) {
    return stat(__DIR__);
  }
  else {

    // Create a tmp file with the contents and get its stats.
    $contents = $this
      ->getFileContents($path);
    $resource = tmpfile();
    fwrite($resource, $contents);
    $stat = fstat($resource);
    fclose($resource);
    return $stat;
  }
}