Packageindex Classtrees Modulegroups Elementlist Report XML Files

File: /home/inri/public_html/daCode-HEAD/daCode/src/phplib/tar.php3
daCode -

Tar

Tar

Create and extract tar archives

 

private class Tar

Create and extract tar archives

daCode http://www.dacode.org/
src/phplib/tar.php3
$Id: tar.php3,v 1.19 2002/05/13 21:34:03 jbcombes Exp $

AuthorsDenis Barbier <barbier@linuxfr.org>

 

Public Method Summary

void

tar()

Class constructor
integer

extract(string $filename, boolean $gz, [ mixed $subs, string $destdir, string $filemode, string $dirmode ])

Extract a tar file
mixed

files(string $filename, boolean $gz, [ mixed $subs, string $destdir ])

Display contents of a tar file
mixed

file_content(string $filename, boolean $gz, string $file, [ mixed $subs ])

Show content of a file in the archive
void

create(string $filename, string $contents, [ boolean $gz, mixed $excludes, mixed $subs, string $fromdir ])

Write an archive

Private Method Summary

void

verbose(string $string)

Print a string if debuging is welcome
integer

fopen(string $filename, string $mode)

Opens a file, be it gzipped or not
void

fclose(integer $fd)

Closes a file
string

fread(integer $fd, integer $size)

Reads from file
void

fwrite(integer $fd, string $string, [ integer $size ])

Writes to a file
boolean

feof(integer $fd)

Determines if EOF has been passed
mixed

open_read(string $filename, [ string $destdir ])

Open a tarfile, it may be at a different location
array

read_header(integer $fd, array $subs)

Read a 512-byte block containing file informations
string

read_body(integer $fd, integer $type, integer $size)

Read file contents
void

display_header(array $header)

Display header informations
integer

open_write(string $filename, [ string $fromdir ])

Open a tarfile for writing
string

compute_checksum(string $bindata)

Compute checksum
void

write_header(integer $fd, array $header)

Write a 512-byte block containing file informations
void

write_body(integer $fd, integer $type, integer $size, integer $name)

Write file contents
void

add_entry(integer $fd, integer $name, array $excludes, array $subs)

Add an entry to the tarfile

Private Field Summary

array

$format

Array describing tar format
string

$x_fmt

Unknown..
string

$c_fmt

Unknown
boolean

$begin

When set to 1, file descriptor points to a header, otherwise it points to body file
boolean

$debug

Controls whether we shall print debugung info
boolean

$noact

When set, do not perform any action

Public Method Details

tar

public void tar( )

  Class constructor

Returns void


extract

public integer extract( string $filename, boolean $gz, [ mixed $subs, string $destdir, string $filemode, string $dirmode ] )

  Extract a tar file
May call echo on error

Parameter
string $filename
of the file to extract
boolean $gz
if file is zipped
mixed $subs = >>""<<
substitutions to perform on headers or empty string
string $destdir = >>""<<
directory
string $filemode = >>"0644"<<
for created files
string $dirmode = >>"0755"<<
for the directories ro create
Returns integer

0 if failure, file descriptor on success


files

public mixed files( string $filename, boolean $gz, [ mixed $subs, string $destdir ] )

  Display contents of a tar file

Parameter
string $filename
of the file to extract
boolean $gz
if file is zipped
mixed $subs = >>""<<
substitutions to perform on headers or empty string
string $destdir = >>""<<
directory
Returns mixed

array list of file on success, void on failure


file_content

public mixed file_content( string $filename, boolean $gz, string $file, [ mixed $subs ] )

  Show content of a file in the archive

Parameter
string $filename
of the file to extract
boolean $gz
if file is zipped
string $file
of the file we wannna display
mixed $subs = >>""<<
substitutions to perform on headers or empty string
Returns mixed

array list of file on success, void on failure


create

public void create( string $filename, string $contents, [ boolean $gz, mixed $excludes, mixed $subs, string $fromdir ] )

  Write an archive

Parameter
string $filename
name
string $contents
of the file
boolean $gz = >>false<<
if file is to be gzipped
mixed $excludes = >>""<<
string or array of i=filenames to exclude
mixed $subs = >>""<<
empty string or array of substitutions to perform on archive headers
string $fromdir = >>""<<
where the files of the archive come from???
Returns void


Private Method Details

verbose

private void verbose( string $string )

  Print a string if debuging is welcome
Calls echo in debuging mode.

Parameter
string $string
string to print
Returns void


fopen

private integer fopen( string $filename, string $mode )

  Opens a file, be it gzipped or not

Parameter
string $filename
of the file
string $mode
mode (r or w)
Returns integer

file descriptor


fclose

private void fclose( integer $fd )

  Closes a file

Parameter
integer $fd
descriptor
Returns void


fread

private string fread( integer $fd, integer $size )

  Reads from file
Behaves as fread standard function.

Parameter
integer $fd
descriptor
integer $size
of bytes to read
Returns string

the value read


fwrite

private void fwrite( integer $fd, string $string, [ integer $size ] )

  Writes to a file
see normal fwrite.

Parameter
integer $fd
descriptor
string $string
to write
integer $size = >>0<<
of data to write
Returns void


feof

private boolean feof( integer $fd )

  Determines if EOF has been passed

Parameter
integer $fd
descriptor
Returns boolean

true if EOF reached or error, false otherwise


open_read

private mixed open_read( string $filename, [ string $destdir ] )

  Open a tarfile, it may be at a different location
Calls echo on failure

Parameter
string $filename
name of the file
string $destdir = >>""<<
where archive is to be unpacked
Returns mixed

integer file descriptor on success, void on failure


read_header

private array read_header( integer $fd, array $subs )

  Read a 512-byte block containing file informations
Calls echo on failure

Parameter
integer $fd
descriptor
array $subs
to perform on headers ????
Returns array

the headers of the tar file


read_body

private string read_body( integer $fd, integer $type, integer $size )

  Read file contents
Calls echo on failure

Parameter
integer $fd
descriptor
integer $type
of the file to read in archive
integer $size
of data to read
Returns string

data read, empty string on failure


display_header

private void display_header( array $header )

  Display header informations

Parameter
array $header
name=> value of the header
Returns void


open_write

private integer open_write( string $filename, [ string $fromdir ] )

  Open a tarfile for writing

Parameter
string $filename
of the file
string $fromdir = >>""<<
where the file is to be created
Returns integer

file descriptor on success, vvoid on failure


compute_checksum

private string compute_checksum( string $bindata )

  Compute checksum

Parameter
string $bindata
which we wnt the chacksum
Returns string

the checksum


write_header

private void write_header( integer $fd, array $header )

  Write a 512-byte block containing file informations
Calls echo on failure

Parameter
integer $fd
descriptor
array $header
to write
Returns void


write_body

private void write_body( integer $fd, integer $type, integer $size, integer $name )

  Write file contents
Calls echo on failure

Parameter
integer $fd
descriptor
integer $type
of file
integer $size
of file to write
integer $name
of file to write
Returns void


add_entry

private void add_entry( integer $fd, integer $name, array $excludes, array $subs )

  Add an entry to the tarfile

Parameter
integer $fd
descriptor
integer $name
of file to write
array $excludes
to exclude
array $subs
to performs
Returns void


Private Field Details

$format

private array $format

>><<

Array describing tar format


$x_fmt

private string $x_fmt

>><<

Unknown..


$c_fmt

private string $c_fmt

>><<

Unknown


$begin

private boolean $begin

>><<

When set to 1, file descriptor points to a header, otherwise it points to body file


$debug

private boolean $debug

>><<

Controls whether we shall print debugung info


$noact

private boolean $noact

>><<

When set, do not perform any action



Packageindex Classtrees Modulegroups Elementlist Report XML Files
PHPDoc 1.0beta