\seekquarry\yioop\libraryPartialZipArchive

Used to extract files from an initial segment or a fragment of a ZIP Archive.

Summary

Methods
Properties
Constants
__construct()
numFiles()
getNameIndex()
getFromName()
$zip_directory
$zip_file_names
NO_COMPRESSION
DEFLATE
ENHANCED_DEFLATE
LOCAL_FILE_HEADER
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Constants

NO_COMPRESSION

NO_COMPRESSION

ZIP code to indicate compression type is no compression used

DEFLATE

DEFLATE

ZIP code to indicate compression type is deflate

ENHANCED_DEFLATE

ENHANCED_DEFLATE

ZIP code to indicate compression type is enhanced deflate (4gb barrier passable)

LOCAL_FILE_HEADER

LOCAL_FILE_HEADER

Byte string to indicate start of a local file header, used to find locations of all the files stored in ZIP fragment we have

Properties

$zip_directory

$zip_directory : array

Stores path/filename -> (compression type, compressed file) associations for all files in the archive that were extractable from the given zip archive fragment

Type

array

$zip_file_names

$zip_file_names : array

Stores path/filenames that were discovered in the initial segment of this zip archive

Type

array

Methods

__construct()

__construct(string  $zip_string) 

Sets up a PartialZipArchive so that files can be extracted from it.

To this it populates the two field variables @see $zip_directory and @see $zip_filenames. Offsets used in the code for extracting various fields out of a zip archive local file header were gotten from https://en.wikipedia.org/wiki/ZIP%28file_format%29 Note the code for the constructor justs splits the whole string into parts on the string @see LOCAL_FILE_HEADER. It doesn't bother to try to use the zip archive's directory (which might not be in the portion of this zip archive given). It is possible for a file contained in archive to actual have within it the string LOCAL_FILE_HEADER, in which case that file would be screwed up by our approach.

Parameters

string $zip_string

a substring of a zip archive file

numFiles()

numFiles() : integer

Returns the total number of files that were detected in the zip archive fragment.

Returns

integer —

number of files found in archive

getNameIndex()

getNameIndex(integer  $index) : string

Returns the file name for the ith file that was extractable from the archive string used in the constructor.

Parameters

integer $index

the number of file want

Returns

string —

its corresponding file name

getFromName()

getFromName(string  $file_name) : mixed

Returns from the PartialZipArchive the uncompressed contents of the provided path/filename if found, and false otherwise.

Parameters

string $file_name

contains complete path and file_name of afile

Returns

mixed —

uncompressed file contents if found and extractable, false otherwise