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

Breadcrumb

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

function vfsStreamWrapper::stream_truncate

truncates a file to a given length

@since 1.1.0

Parameters

int $size length to truncate file to:

Return value

bool

File

vendor/mikey179/vfsstream/src/main/php/org/bovigo/vfs/vfsStreamWrapper.php, line 474

Class

vfsStreamWrapper
Stream wrapper to mock file system requests.

Namespace

org\bovigo\vfs

Code

public function stream_truncate($size) {
    if (self::READONLY === $this->mode) {
        return false;
    }
    if ($this->content
        ->isWritable(vfsStream::getCurrentUser(), vfsStream::getCurrentGroup()) === false) {
        return false;
    }
    if ($this->content
        ->getType() !== vfsStreamContent::TYPE_FILE) {
        return false;
    }
    if (self::$quota->isLimited() && $this->content
        ->size() < $size) {
        $maxSize = self::$quota->spaceLeft(self::$root->sizeSummarized());
        if (0 === $maxSize) {
            return false;
        }
        if ($size > $maxSize) {
            $size = $maxSize;
        }
    }
    return $this->content
        ->truncate($size);
}

API Navigation

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