apidoc
[ class tree: apidoc ] [ index: apidoc ] [ all elements ]

Class: File_Archive_Reader

Source Location: /File_Archive-1.2.0/File/Archive/Reader.php

Class Overview


Abstract base class for all the readers


Methods


Child classes:

File_Archive_Reader_Memory
A reader that takes its input from a memory buffer
File_Archive_Reader_File
Reader that represents a single file
File_Archive_Reader_Concat
This reader provides one single file that is the concatenation of the data of
File_Archive_Reader_Archive
Base class for all the archive readers (that read from a single file)
File_Archive_Reader_Relay
This reader appear exactly as $source does

Inherited Variables

Inherited Methods


Class Details

[line 41]
Abstract base class for all the readers

A reader is a compilation of serveral files that can be read



[ Top ]


Method Detail

close   [line 208]

void close( [$recursive $recursive = false])

Put back the reader in the state it was before the first call to next()

Overridden in child classes as:

File_Archive_Reader_Memory::close()
File_Archive_Reader_File::close()
File_Archive_Reader_Concat::close()
File_Archive_Reader_Archive::close()
Close the source if it was given closed in the constructor
File_Archive_Reader_Gzip::close()
File_Archive_Reader_Tar::close()
File_Archive_Reader_Bzip2::close()
File_Archive_Reader_Zip::close()
File_Archive_Reader_Ar::close()
File_Archive_Reader_Relay::close()
File_Archive_Reader_Uncompress::close()
File_Archive_Reader_Multi::close()
File_Archive_Reader_Directory::close()

Parameters:

$recursive   $recursive   —  If true, close eventual inner writer even if it was given opened?

[ Top ]

extract   [line 251]

void extract( &$writer, [bool $autoClose = true], [int $bufferSize = 102400], File_Archive_Writer $writer)

Sends the whole reader to $writer and close the reader

Parameters:

File_Archive_Writer   $writer   —  Where to write the files of the reader
bool   $autoClose   —  If true, close $writer at the end of the function. Default value is true
int   $bufferSize   —  Size of the chunks that will be sent to the writer Default value is 100kB
   &$writer   — 

[ Top ]

extractFile   [line 291]

void extractFile( string $filename, &$writer, [bool $autoClose = true], [int $bufferSize = 8192], File_Archive_Writer $writer)

Extract only one file (given by the URL)

Parameters:

string   $filename   —  URL of the file to extract from this
File_Archive_Writer   $writer   —  Where to write the file
bool   $autoClose   —  If true, close $writer at the end of the function Default value is true
int   $bufferSize   —  Size of the chunks that will be sent to the writer Default value is 100kB
   &$writer   — 

[ Top ]

getData   [line 180]

void getData( [ $length = -1])

Reads some data from the current file

If the end of the file is reached, returns null If $length is not specified, reads up to the end of the file If $length is specified reads up to $length


Overridden in child classes as:

File_Archive_Reader_Memory::getData()
File_Archive_Reader_File::getData()
File_Archive_Reader_Concat::getData()
File_Archive_Reader_Gzip::getData()
File_Archive_Reader_Tar::getData()
File_Archive_Reader_Bzip2::getData()
File_Archive_Reader_Zip::getData()
File_Archive_Reader_Ar::getData()
File_Archive_Reader_Relay::getData()

Parameters:

   $length   — 

[ Top ]

getDataFilename   [line 172]

the getDataFilename( )

If the current file of the archive is a physical file,
  • Return:

    name of the physical file containing the data or null if no such file exists

    The data filename may not be the same as the filename.


Overridden in child classes as:

File_Archive_Reader_File::getDataFilename()
File_Archive_Reader_Relay::getDataFilename()

[ Top ]

getFileList   [line 131]

array getFileList( )

Returns the list of filenames from the current pos to the end of the source The source will be closed after having called this function This function goes through the whole archive (which may be slow).

If you intend to work on the reader, doing it in one pass would be faster

  • Return: filenames from the current pos to the end of the source

[ Top ]

getFilename   [line 118]

string getFilename( )

Returns the name of the file currently read by the reader

Warning: undefined behaviour if no call to next have been done or if last call to next has returned false

  • Return: Name of the current file

Overridden in child classes as:

File_Archive_Reader_Memory::getFilename()
File_Archive_Reader_File::getFilename()
File_Archive_Reader_Concat::getFilename()
File_Archive_Reader_Gzip::getFilename()
Return the name of the single file contained in the archive deduced from the name of the archive (the extension is removed)
File_Archive_Reader_Tar::getFilename()
File_Archive_Reader_Bzip2::getFilename()
Return the name of the single file contained in the archive deduced from the name of the archive (the extension is removed)
File_Archive_Reader_Zip::getFilename()
File_Archive_Reader_Ar::getFilename()
File_Archive_Reader_Relay::getFilename()
File_Archive_Reader_AddBaseName::getFilename()
File_Archive_Reader_ChangeBaseName::getFilename()
File_Archive_Reader_Directory::getFilename()

[ Top ]

getMime   [line 158]

void getMime( )

Returns the MIME associated with the current file

The default function does that by looking at the extension of the file


Overridden in child classes as:

File_Archive_Reader_Memory::getMime()
File_Archive_Reader_File::getMime()
File_Archive_Reader_Concat::getMime()
File_Archive_Reader_Relay::getMime()

[ Top ]

getStandardURL   [line 95]

void getStandardURL( string $path)

Returns the standard path

Changes \ to / Removes the .. and . from the URL


Parameters:

string   $path   —  a valid URL that may contain . or .. and \

[ Top ]

getStat   [line 152]

void getStat( )

Returns an array of statistics about the file (see the PHP stat function for more information)

The returned array may be empty, even if readers should try their best to return as many data as possible


Overridden in child classes as:

File_Archive_Reader_Memory::getStat()
File_Archive_Reader_File::getStat()
File_Archive_Reader_Concat::getStat()
File_Archive_Reader_Tar::getStat()
File_Archive_Reader_Zip::getStat()
File_Archive_Reader_Ar::getStat()
File_Archive_Reader_Relay::getStat()

[ Top ]

makeAppendWriter   [line 377]

a makeAppendWriter( [ $fileModif = true])

This is equivalent to move to the end of the archive and calling makeWriter
  • Return: writer that will allow to append files to an existing archive
  • See: makeWriter

Parameters:

   $fileModif   — 

[ Top ]

makeWriter   [line 366]

File_Archive_Writer makeWriter( [bool $fileModif = true], [int $seek = 0])

Returns a writer that will start writing at the current pos in the source Any data (from current file or any other file) located after current pos will be erased.

For security reasons, calling makeWriter on a directory reader will not erase any file though. $this->close will be called and after this function the reader is invalid (and should no longer be used).

If $fileModif is true, the writer will allow editing the current file (or the last file if the end of the archive has been reached) Thus it is an error to call makeWriter with fileModif to true if the reader has not been opened (no call to next() have been done, or first call to next returned false). In this case, $seek allows to change the position from where the file must be edited

If $fileModif is false, the writer will not allow to edit the current file, and the first function call should be new file. The current file will be left unchanged If the first function call is writeData, the behaviour is undefined (it will generally result in invalid archives). In this case, $seek is not used

Here is how to append a single file to an existing zip archive <sample> $archive = File_Archive::read('archive.zip/'); $file = File_Archive::read('foo.txt'); $file->extract($source->makeAppendWriter()); </sample>

Append the content of a tgz archive to an existing zip archive <sample> $archive = File_Archive::read('archive.zip/'); $file = File_Archive::read('archive.tgz/'); $file->extract($source->makeAppendWriter()); </sample>

  • Return: Writer that appends data to the ressource of this reader, starting at the current location

Overridden in child classes as:

File_Archive_Reader_Memory::makeWriter()
File_Archive_Reader_File::makeWriter()
File_Archive_Reader_Concat::makeWriter()
File_Archive_Reader_Gzip::makeWriter()
File_Archive_Reader_Tar::makeWriter()
File_Archive_Reader_Bzip2::makeWriter()
File_Archive_Reader_Zip::makeWriter()
File_Archive_Reader_Ar::makeWriter()
File_Archive_Reader_Relay::makeWriter()
File_Archive_Reader_Directory::makeWriter()

Parameters:

int   $seek   —  The new writer will be opened seek bytes after the current position Seek can be positive or negative If current file pos + seek < 0 or current file pos + seek > current file size, we have an undefined behaviour
bool   $fileModif   —  Set to false only if you will call newFile or close first on the returned writer (and thus will not modify the current file of the reader) Setting this parameter to false can speed up a lot the process If $fileModif is false, $seek will not be taken into account (since the writer will not write in the current file)

[ Top ]

next   [line 48]


select   [line 61]

bool select( string $filename, [bool $close = true])

Move to the next file whose name is in directory $filename or is exactly $filename
  • Return: whether the file was found in the archive or not

Overridden in child classes as:

File_Archive_Reader_Uncompress::select()

Parameters:

string   $filename   —  Name of the file to find in the archive
bool   $close   —  If true, close the reader and search from the first file

[ Top ]

sendData   [line 217]

void sendData( &$writer, [ $bufferSize = 102400])

Sends the current file to the Writer $writer

The data will be sent by chunks of at most $bufferSize bytes


Parameters:

   &$writer   — 
   $bufferSize   — 

[ Top ]

skip   [line 191]

void skip( $length)

Skip some data and returns how many bytes have been skipped

This is strictly equivalent to return strlen(getData($length)) But could be far more efficient


Overridden in child classes as:

File_Archive_Reader_Memory::skip()
File_Archive_Reader_File::skip()
File_Archive_Reader_Concat::skip()
File_Archive_Reader_Tar::skip()
File_Archive_Reader_Zip::skip()
File_Archive_Reader_Relay::skip()

Parameters:

   $length   — 

[ Top ]


Documentation generated on Mon, 11 Mar 2019 14:19:43 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.