Example #1
0
 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);
 }
Example #2
0
 /**
  * Initializes the Tar and tries to read the first entry from the archive.
  *
  * At initialization it sets the blockFactor to $blockFactor. Each tar archive
  * has always $blockFactor of blocks ( 0, $blockFactor, 2 * $blockFactor, etc ).
  *
  * The Tar archive works with blocks, so therefore the first parameter expects
  * the archive as a blockFile.
  *
  * @param ezcArchiveBlockFile $blockFile
  * @param int $blockFactor
  */
 public function __construct(ezcArchiveBlockFile $blockFile, $blockFactor = 20)
 {
     parent::__construct($blockFile, $blockFactor);
 }