org\bovigo\vfs\content\StringBasedFileContent::truncate PHP Method

truncate() public method

Truncates a file to a given length
public truncate ( integer $size ) : boolean
$size integer length to truncate file to
return boolean
    public function truncate($size)
    {
        if ($size > $this->size()) {
            // Pad with null-chars if we're "truncating up"
            $this->content .= str_repeat("", $size - $this->size());
        } else {
            $this->content = substr($this->content, 0, $size);
        }
        return true;
    }