You are here

public function LargeFileContent::truncate in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/content/LargeFileContent.php \org\bovigo\vfs\content\LargeFileContent::truncate()

Truncates a file to a given length

Parameters

int $size length to truncate file to:

Return value

bool

Overrides FileContent::truncate

File

vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/content/LargeFileContent.php, line 153

Class

LargeFileContent
File content implementation to mock large files.

Namespace

org\bovigo\vfs\content

Code

public function truncate($size) {
  $this->size = $size;
  foreach (array_filter(array_keys($this->content), function ($pos) use ($size) {
    return $pos >= $size;
  }) as $removePos) {
    unset($this->content[$removePos]);
  }
  return true;
}