Example #1
0
 /**
  * Truncate file to a given size.
  *
  * @param int $size
  *
  * @return static
  *
  * @throws FileNotFoundException If the file does not exists
  * @throws NotAFileException If the pathname is not a file.
  *
  * @api
  */
 public function truncate($size = 0)
 {
     $this->pathname->rootAdapter()->truncate($this->pathname, $size);
     $eventDispatcher = $this->filesystem->getEventDispatcher();
     if ($eventDispatcher) {
         $event = new TruncateEvent($this->filesystem, $this, $size);
         $eventDispatcher->dispatch(FiliciousEvents::TRUNCATE, $event);
     }
     return $this;
 }