public function testTruncateAmountOfBlocks() { if (!$this->canWrite) { return; } $blockFile = new ezcArchiveBlockFile($this->file); $i = 1; while ($blockFile->next()) { $i++; } $this->assertEquals(20, $i, "Expected 20 blocks in the file."); $blockFile->seek(2); $this->assertFalse($blockFile->isNullBlock(), "Didn't expect a null block."); $blockFile->seek(3); $this->assertFalse($blockFile->isNullBlock(), "Didn't expect a null block."); $blockFile->seek(4); $this->assertTrue($blockFile->isNullBlock(), "Expected a null block."); // Give the block File to the archive. $archive = new ezcArchiveV7Tar($blockFile); $entry = $archive->current(); // A non rewinded block file, does that work? $this->assertEquals("file1.txt", $entry->getPath()); $archive->truncate(1); // keep the first file. $archive->close(); $blockFile = new ezcArchiveBlockFile($this->file); // Should be 20 blocks.. $i = 1; while ($blockFile->next()) { $i++; } $this->assertEquals(20, $i, "Expected 20 blocks in the file."); $blockFile->seek(0); $this->assertFalse($blockFile->isNullBlock(), "Didn't expect a null block."); $blockFile->seek(1); $this->assertFalse($blockFile->isNullBlock(), "Didn't expect a null block."); $blockFile->seek(2); $this->assertTrue($blockFile->isNullBlock(), "Expected a null block."); unset($blockFile); }