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

Class: File_Archive_Reader

Source Location: /File_Archive-1.1.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 183]


extract   [line 222]

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

Sends the whole reader to $writer

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 257]

void extractFile( string $filename, &$writer, [bool $autoClose = true], [int $bufferSize = 102400], 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 158]

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_Relay::getData()

Parameters:

   $length   — 

[ Top ]

getDataFilename   [line 150]

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 ]

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_Relay::getFilename()
File_Archive_Reader_AddBaseName::getFilename()
File_Archive_Reader_ChangeBaseName::getFilename()
File_Archive_Reader_Directory::getFilename()

[ Top ]

getMime   [line 136]

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 130]

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_Relay::getStat()

[ Top ]

makeAppendWriter   [line 314]

a makeAppendWriter( )

  • Return: writer that will allow to append files to an existing archive

[ Top ]

makeWriter   [line 306]

void makeWriter( [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. No file will be erased though (so for file and directory readers, the file and directory will not be deleted) $this->close will be called. $this should not be used until the returned writer has been closed

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>


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_Relay::makeWriter()
File_Archive_Reader_AddBaseName::makeWriter()
File_Archive_Reader_ChangeBaseName::makeWriter()
File_Archive_Reader_Directory::makeWriter()

Parameters:

int   $seek   —  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

[ 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 192]

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 169]

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:20:31 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.