public function vfsStreamWrapper::stream_truncate in Zircon Profile 8.0
Same name and namespace in other branches
- 8 vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/vfsStreamWrapper.php \org\bovigo\vfs\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 468
Class
- vfsStreamWrapper
- Stream wrapper to mock file system requests.
Namespace
org\bovigo\vfsCode
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);
}