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

Class: File_Archive_Reader

Source Location: /File_Archive-1.0.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

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]

void close( )

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()

[ Top ]

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()

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()

[ 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()

[ 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()

[ 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()

[ Top ]

next   [line 48]

bool next( )

Move to the next file in the reader
  • Return: true iif no more files are available

Overridden in child classes as:

File_Archive_Reader_Memory::next()
The subclass should overwrite this function to change the filename, stat
File_Archive_Reader_File::next()

[ Top ]

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

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()

Parameters:

   $length   — 

[ Top ]


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