/** * Removed all data from file and sets pointer to 0 * * @param int $new_size * * @return void */ public function truncate($new_size = 0) { $this->position(0); $newData = substr($this->file->data(), 0, $new_size); $newData = false === $newData ? '' : $newData; $this->file->setData($newData); $this->file->setModificationTime(time()); $this->file->setChangeTime(time()); return; }
public function testOffsetPositionMovesPointerCorrectly() { $file = new File('/file'); $file->setData('data'); $handler = new FileHandler(); $handler->setFile($file); $handler->offsetPosition(2); $this->assertEquals(2, $handler->position()); $handler->offsetPosition(2); $this->assertEquals(4, $handler->position()); }