Archive: ezcArchiveV7Tar
[ ]
[ ]
[ ]
[ ]
[ ]
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
Inherited Constants
From
ezcArchive:
Member Variables
|
protected int |
$addedBlocks
= 0
Stores the number of added blocks. |
|
protected bool |
$addedBlocksNotReliable
= false
Specifies if unreliable blocks were added. |
|
protected int |
$blockFactor
= 20
Tar archives have always $blockFactor of blocks. |
|
protected bool |
$hasNullBlocks
Specifies if the archive contains null blocks. |
|
protected array(int) |
$headerPositions
Stores the block number where the header starts.
The fileNumber is the index of the array. |
|
protected array(ezcArchiveV7Header) |
$headers
Stores all the headers from the archive.
The first header of the archive has index zero. The ezcArchiveV7Header or a subclass from this header is stored in the array. createTarHeader() will create the correct header. |
Inherited Member Variables
From
ezcArchive:
Method Summary
|
public ezcArchiveV7Tar |
__construct(
$file, [$blockFactor = 20] )
Initializes the Tar and tries to read the first entry from the archive. |
|
public void |
__destruct(
)
Closes the archive. |
|
public bool |
algorithmCanWrite(
)
Returns true because the TAR_V7 algorithm can write. |
|
public bool |
append(
$files, $prefix )
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 bool |
appendHeaderAndFileToCurrent(
$entry )
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 bool |
appendToCurrent(
$files, $prefix )
Appends a file to the archive after the current entry. |
|
public void |
close(
)
Closes the archive correctly. |
|
protected ezcArchiveV7Header |
createTarHeader(
[$file = null] )
Creates the a new tar header for this class. |
|
public int |
getAlgorithm(
)
Returns the value which specifies a TAR_V7 algorithm. |
|
protected bool |
readCurrentFromArchive(
)
Read the current entry from the archive. |
|
public bool |
truncate(
[$fileNumber = 0] )
Truncates the archive to $fileNumber of files. |
|
protected bool |
writeCurrentDataToFile(
$targetPath )
Writes the file data from the current entry to the given file. |
|
public void |
writeEnd(
)
Writes the end of the archive. |
Inherited Methods
From
ezcArchive :
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
__destruct
void __destruct(
)
Closes the archive.
algorithmCanWrite
bool algorithmCanWrite(
)
Returns true because the TAR_V7 algorithm can write.
See also:
isWritable().
Redefinition of
Redefined in descendants as
append
bool append(
string|array(string)
$files, string
$prefix )
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 |
$files |
string|array(string) |
Add the files and or directories to the archive. |
$prefix |
string |
First part of the path used in $files. |
Throws
| Class | Description |
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. |
ezcArchiveException |
if the archive is closed. |
See also:
ezcArchiveV7Tar::appendToCurrent().
Redefinition of
| Method |
Description |
ezcArchive::append() |
Appends 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. |
appendHeaderAndFileToCurrent
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
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
bool appendToCurrent(
string|array(string)
$files, string
$prefix )
Appends a file to the archive after the current entry.
One or multiple files can be added directly after the current file. The remaining entries after the current are removed from the archive!
The $files can either be a string or an array of strings. Which, respectively, represents a single file or multiple files.
$prefix specifies the begin part of the $files path that should not be included in the archive. The files in the archive are always stored relatively.
Example:
1. $tar = ezcArchive( "/tmp/my_archive.tar", ezcArchive::TAR );
2.
3. // Append two files to the end of the archive.
4. $tar->seek( 0, SEEK_END );
5. $tar->appendToCurrent( array( "/home/rb/file1.txt", "/home/rb/file2.txt" ), "/home/rb/" );
When multiple files are added to the archive at the same time, thus using an array, does not necessarily produce the same archive as repeatively adding one file to the archive. For example, the Tar archive format, can detect that files hardlink to each other and will store it in a more efficient way.
Parameters
| Name |
Type |
Description |
$files |
string|array(string) |
Array or a single path to a file. |
$prefix |
string |
First part of the path used in $files. |
Throws
| Class | Description |
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. |
ezcArchiveException |
if the archive is closed. |
Redefinition of
close
void close(
)
Closes the archive correctly.
Redefinition of
createTarHeader
ezcArchiveV7Header createTarHeader(
[string|null
$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.
Parameters
| Name |
Type |
Description |
$file |
string|null |
|
Redefined in descendants as
getAlgorithm
int getAlgorithm(
)
Returns the value which specifies a TAR_V7 algorithm.
Redefinition of
Redefined in descendants as
readCurrentFromArchive
bool 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.
Throws
| Class | Description |
ezcArchiveBlockSizeException |
if the file is empty or if the file is not valid |
truncate
bool truncate(
[int
$fileNumber = 0] )
Truncates the archive to $fileNumber of files.
The $fileNumber parameter specifies the amount of files that should remain. If the default value, zero, is used then the entire archive file is cleared.
Parameters
| Name |
Type |
Description |
$fileNumber |
int |
|
Throws
| Class | Description |
ezcArchiveException |
if the archive is closed |
ezcBaseFilePermissionException |
if the file is read-only or if the current algorithm cannot write |
Redefinition of
writeCurrentDataToFile
bool writeCurrentDataToFile(
string
$targetPath )
Writes the file data from the current entry to the given file.
Parameters
| Name |
Type |
Description |
$targetPath |
string |
The absolute or relative path of the target file. |
Redefinition of
writeEnd
void writeEnd(
)
Writes the end of the archive.
Throws
| Class | Description |
ezcArchiveException |
if the archive is closed |
Last updated: Mon, 10 Nov 2008