public function testTruncateRemovesDataAndResetsPointer() { $file = new File('/file'); $file->setData('data'); $handler = new FileHandler(); $handler->setFile($file); $handler->truncate(); $this->assertEmpty($file->data()); $this->assertEquals(0, $handler->position()); //truncate to size $file->setData('data--'); $handler->truncate(4); $this->assertEquals(0, $handler->position()); $this->assertEquals('data', $file->data()); }
/** * Truncates file to given size * * @param int $new_size * * @return bool */ public function stream_truncate($new_size) { $this->currently_opened->truncate($new_size); clearstatcache(); return true; }