Path

ez components / documentation / api reference / 2006.2 / archive


eZ Components 2006.2

Archive: ezcArchiveV7Tar

[ Tutorial ] [ Class tree ] [ Element index ] [ ChangeLog ] [ Credits ]

Class: ezcArchiveV7Tar

The ezcArchiveV7Tar class implements the Tar v7 archive format. [source]
ezcArchiveV7Tar is a subclass from ezcArchive that provides the common interface. Tar v7 algorithm specific methods are implemented in this class.
ezcArchiveV7Tar reads on creation only the first ezcArchiveEntry from the archive. When needed next entries are read.
The V7 Tar algorithm is most basic implementation of Tar. This format has the following characteristics:
  • Filenames up to 100 characters.
  • Stores the file permissions.
  • Stores the owner and group by ID.
  • Stores the last modification time.
  • Can archive: regular files and symbolic links.
  • Maximum file size: 8 Gygabyte.

Parents

ezcArchive
   |
   --ezcArchiveV7Tar

Descendents

Child Class Description
ezcArchiveUstarTar The ezcArchiveUstarTar class implements the Tar ustar archive format.

Constants

BLOCK_SIZE = 512 Amount of bytes in a block.

Inherited Constants

From ezcArchive:
ezcArchive::BZIP2    BZIP2 compression format.
ezcArchive::GZIP    Gnu ZIP compression format.
ezcArchive::TAR    Normal tar archive.
ezcArchive::TAR_GNU    GNU tar archive.
ezcArchive::TAR_PAX    PAX tar archive.
ezcArchive::TAR_USTAR    USTAR tar archive.
ezcArchive::TAR_V7    Tar version 7 archive.
ezcArchive::ZIP    ZIP archive.

Member Variables

protected mixed $addedBlocks = 0
protected mixed $addedBlocksNotReliable = false
protected int $blockFactor = 20
Tar archives have always $blockFactor of blocks.
protected mixed $hasNullBlocks
protected array(int) $headerPositions
Stores the block number where the header starts.
protected array(ezcArchiveV7Header) $headers
Stores all the headers from the archive.

Inherited Member Variables

From ezcArchive:
protected  ezcArchive::$completed
protected  ezcArchive::$entries
protected  ezcArchive::$entriesRead
protected  ezcArchive::$file
protected  ezcArchive::$fileNumber

Method Summary

public ezcArchiveV7Tar __construct( $file, [$blockFactor = 20] )
Initializes the Tar and tries to read the first entry from the archive.
public void __destruct( )
public void algorithmCanWrite( )
public void append( $files, $prefix, $entries )
Append a file or directory to the end of the archive. Multiple files or directory can be added to the archive when an array is used as input parameter.
protected void appendHeaderAndFileToCurrent( $entry, $file )
Appends the given ezcArchiveBlockFile $file and ezcArchiveEntry $entry to the archive file.
protected void appendNullBlocks( )
Appends zero or more null blocks to the end of the archive, so that it matches the $blockFactor.
public void appendToCurrent( $files, $prefix )
public void close( )
protected ezcArchiveV7Header createTarHeader( [$file = null] )
Creates the a new tar header for this class.
public void getAlgorithm( )
protected void readCurrentFromArchive( )
Read the current entry from the archive.
public void truncate( [$fileNumber = 0] )
protected void writeCurrentDataToFile( $targetPath )
public void writeEnd( )

Inherited Methods

From ezcArchive :
public abstract bool ezcArchive::algorithmCanWrite()
Returns true if writing to the archive is implemented, otherwise false.
public abstract void ezcArchive::append()
public abstract void ezcArchive::appendToCurrent()
Appends a file to the archive after the current entry.
public void ezcArchive::close()
Close the current archive.
protected void ezcArchive::createDefaultDirectory()
Creates all the directories needed to create the file $file.
protected static ezcArchive ezcArchive::createInstance()
Returns an instance of the archive with the given type.
public ezcArchiveEntry ezcArchive::current()
Returns the current ezcArchiveEntry if it is valid, otherwise false is returned.
public void ezcArchive::extract()
Extract entries from the archive to the target directory.
public bool ezcArchive::extractCurrent()
Extract the current entry to which the iterator points.
public abstract int ezcArchive::getAlgorithm()
Returns the algorithm that is used currently.
protected void ezcArchive::getEntries()
Get the file entries.
public array(string) ezcArchive::getListing()
Returns an array that lists the content of the archive.
public static ezcArchive ezcArchive::getTarInstance()
Open a tar instance.
public static ezcArchive ezcArchive::getZipInstance()
Open a zip instance. This method is made public for testing purposes, and should not be used.
public bool ezcArchive::isEmpty()
Returns true if the current archive is empty, otherwise false.
public int ezcArchive::key()
Returns the current key, entry number, if it is valid, otherwise false is returned.
public ezcArchiveEntry ezcArchive::next()
Forwards the iterator to the next entry.
public static ezcArchive ezcArchive::open()
Returns a new ezcArchive instance.
public void ezcArchive::rewind()
Rewinds the iterator to the first entry.
public bool ezcArchive::seek()
Search for the entry number.
public abstract void ezcArchive::truncate()
Truncate the archive to $fileNumber of files.
public bool ezcArchive::valid()
Returns true if the iterator points to a valid entry, otherwise false.
protected abstract void ezcArchive::writeCurrentDataToFile()
Writes the file data from the current entry to the given file.
public mixed ezcArchive::__get()
Returns the property $name.
public void ezcArchive::__set()
Sets the property $name to $value.
public string ezcArchive::__toString()
Returns a string which represents all the entries from the archive.

Methods

__construct

ezcArchiveV7Tar __construct( $file, [int $blockFactor = 20] )
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.

Parameters

Name Type Description
$file ezcArchiveBlockFile  
$blockFactor int  

Redefined in descendants as

Method Description
ezcArchiveUstarTar::__construct()  
ezcArchivePaxTar::__construct()  
ezcArchiveGnuTar::__construct()  

__destruct

void __destruct( )

algorithmCanWrite

void algorithmCanWrite( )

Redefinition of

Method Description
ezcArchive::algorithmCanWrite() Returns true if writing to the archive is implemented, otherwise false.

Redefined in descendants as

Method Description
ezcArchiveUstarTar::algorithmCanWrite()  
ezcArchivePaxTar::algorithmCanWrite()  
ezcArchiveGnuTar::algorithmCanWrite()  

append

void append( $files, $prefix, string|array(string) $entries )
Append a file or directory to the end of the archive. Multiple files or directory can be added to the archive when an array is used as input parameter.

Parameters

Name Type Description
$entries string|array(string) Add the files and or directories to the archive.
$files  
$prefix  

Throws

ClassDescription
ezcArchiveWriteException if one of the files cannot be written to the archive.
ezcFileReadException if one of the files cannot be read from the local filesystem.

See also:

ezcArchiveV7Tar::appendToCurrent().

Redefinition of

Method Description
ezcArchive::append()  

appendHeaderAndFileToCurrent

void appendHeaderAndFileToCurrent( ezcArchiveEntry $entry, string $file )
Appends the given ezcArchiveBlockFile $file and ezcArchiveEntry $entry to the archive file.
The $entry will be used to create the correct header, whereas the $file contains the raw data that should be append to the archive.

Parameters

Name Type Description
$file string  
$entry ezcArchiveEntry  

appendNullBlocks

void appendNullBlocks( )
Appends zero or more null blocks to the end of the archive, so that it matches the $blockFactor.
If the archive has already the correct size, no null blocks will be appended. Otherwise as many null blocks are appended (up to $blockFactor - 1) so that it matches the $blockFactor.

appendToCurrent

void appendToCurrent( $files, $prefix )

Parameters

Name Type Description
$files  
$prefix  

Redefinition of

Method Description
ezcArchive::appendToCurrent() Appends a file to the archive after the current entry.

close

void close( )

Redefinition of

Method Description
ezcArchive::close() Close the current archive.

createTarHeader

ezcArchiveV7Header createTarHeader( [mixed $file = null] )
Creates the a new tar header for this class.
Usually this class is reimplemented by other Tar algorithms, and therefore it returns another Tar header.
This method expects an ezcArchiveBlockFile that points to the header that should be read (and created). If null is given as block file, an empty header will be created.

Redefined in descendants as

Method Description
ezcArchiveUstarTar::createTarHeader()  
ezcArchivePaxTar::createTarHeader()  
ezcArchiveGnuTar::createTarHeader()  

getAlgorithm

void getAlgorithm( )

Redefinition of

Method Description
ezcArchive::getAlgorithm() Returns the algorithm that is used currently.

Redefined in descendants as

Method Description
ezcArchiveUstarTar::getAlgorithm()  
ezcArchivePaxTar::getAlgorithm()  
ezcArchiveGnuTar::getAlgorithm()  

readCurrentFromArchive

void readCurrentFromArchive( )
Read the current entry from the archive.
The current entry from the archive is read, if possible. This method will set the $completed to true, if the end of the archive is reached. The $entriesRead will be increased, if the entry is correctly read.

truncate

void truncate( [ $fileNumber = 0] )

Parameters

Name Type Description
$fileNumber  

Redefinition of

Method Description
ezcArchive::truncate() Truncate the archive to $fileNumber of files.

writeCurrentDataToFile

void writeCurrentDataToFile( $targetPath )

Parameters

Name Type Description
$targetPath  

Redefinition of

Method Description
ezcArchive::writeCurrentDataToFile() Writes the file data from the current entry to the given file.

writeEnd

void writeEnd( )

Last updated: Thu, 01 Nov 2007