[ Index ]

PHP Cross Reference of MediaWiki-1.24.0

title

Body

[close]

/includes/utils/ -> ZipDirectoryReader.php (summary)

ZIP file directories reader, for the purposes of upload verification. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

File Size: 732 lines (22 kb)
Included or required:0 times
Referenced: 2 times
Includes or requires: 0 files

Defines 2 classes

ZipDirectoryReader:: (18 methods):
  read()
  __construct()
  execute()
  error()
  readEndOfCentralDirectoryRecord()
  readZip64EndOfCentralDirectoryLocator()
  readZip64EndOfCentralDirectoryRecord()
  findOldCentralDirectory()
  findZip64CentralDirectory()
  readCentralDirectory()
  unpackZip64Extra()
  getFileLength()
  getBlock()
  getSegment()
  getStructSize()
  unpack()
  testBit()
  hexDump()

ZipDirectoryReaderError:: (2 methods):
  __construct()
  getErrorCode()


Class: ZipDirectoryReader  - X-Ref

A class for reading ZIP file directories, for the purposes of upload
verification.

Only a functional interface is provided: ZipFileReader::read(). No access is
given to object instances.

read( $fileName, $callback, $options = array()   X-Ref
Read a ZIP file and call a function for each file discovered in it.

Because this class is aimed at verification, an error is raised on
suspicious or ambiguous input, instead of emulating some standard
behavior.

param: string $fileName The archive file name
param: array $callback The callback function. It will be called for each file
param: array $options An associative array of read options, with the option
return: Status A Status object. The following fatal errors are defined:

__construct( $fileName, $callback, $options )   X-Ref
Private constructor

param: string $fileName
param: callable $callback
param: array $options

execute()   X-Ref
Read the directory according to settings in $this.

return: Status

error( $code, $debugMessage )   X-Ref
Throw an error, and log a debug message

param: mixed $code
param: string $debugMessage

readEndOfCentralDirectoryRecord()   X-Ref
Read the header which is at the end of the central directory,
unimaginatively called the "end of central directory record" by the ZIP
spec.


readZip64EndOfCentralDirectoryLocator()   X-Ref
Read the header called the "ZIP64 end of central directory locator". An
error will be raised if it does not exist.


readZip64EndOfCentralDirectoryRecord()   X-Ref
Read the header called the "ZIP64 end of central directory record". It
may replace the regular "end of central directory record" in ZIP64 files.


findOldCentralDirectory()   X-Ref
Find the location of the central directory, as would be seen by a
non-ZIP64 reader.

return: array List containing offset, size and end position.

findZip64CentralDirectory()   X-Ref
Find the location of the central directory, as would be seen by a
ZIP64-compliant reader.

return: array List containing offset, size and end position.

readCentralDirectory( $offset, $size )   X-Ref
Read the central directory at the given location

param: int $offset
param: int $size

unpackZip64Extra( $extraField )   X-Ref
Interpret ZIP64 "extra field" data and return an associative array.

param: string $extraField
return: array|bool

getFileLength()   X-Ref
Get the length of the file.

return: int

getBlock( $start, $length = null )   X-Ref
Get the file contents from a given offset. If there are not enough bytes
in the file to satisfy the request, an exception will be thrown.

param: int $start The byte offset of the start of the block.
param: int $length The number of bytes to return. If omitted, the remainder
return: string

getSegment( $segIndex )   X-Ref
Get a section of the file starting at position $segIndex * self::SEGSIZE,
of length self::SEGSIZE. The result is cached. This is a helper function
for getBlock().

If there are not enough bytes in the file to satisfy the request, the
return value will be truncated. If a request is made for a segment beyond
the end of the file, an empty string will be returned.

param: int $segIndex
return: string

getStructSize( $struct )   X-Ref
Get the size of a structure in bytes. See unpack() for the format of $struct.

param: array $struct
return: int

unpack( $string, $struct, $offset = 0 )   X-Ref
Unpack a binary structure. This is like the built-in unpack() function
except nicer.

param: string $string The binary data input
param: array $struct An associative array giving structure members and their
param: int $offset The offset into the string at which to start unpacking.
return: array Unpacked associative array. Note that large integers in the input

testBit( $value, $bitIndex )   X-Ref
Returns a bit from a given position in an integer value, converted to
boolean.

param: int $value
param: int $bitIndex The index of the bit, where 0 is the LSB.
return: bool

hexDump( $s )   X-Ref
Debugging helper function which dumps a string in hexdump -C format.

param: string $s

Class: ZipDirectoryReaderError  - X-Ref

Internal exception class. Will be caught by private code.

__construct( $code )   X-Ref
No description

getErrorCode()   X-Ref

return: mixed



Generated: Fri Nov 28 14:03:12 2014 Cross-referenced by PHPXref 0.7.1