PartialZipArchive
in package
Used to extract files from an initial segment or a fragment of a ZIP Archive.
Tags
Table of Contents
- DEFLATE = 8
- ZIP code to indicate compression type is deflate
- ENHANCED_DEFLATE = 9
- ZIP code to indicate compression type is enhanced deflate (4gb barrier passable)
- LOCAL_FILE_HEADER = "PK\x03\x04"
- Byte string to indicate start of a local file header, used to find locations of all the files stored in ZIP fragment we have
- NO_COMPRESSION = 0
- ZIP code to indicate compression type is no compression used
- $zip_directory : array<string|int, mixed>
- Stores path/filename -> (compression type, compressed file) associations for all files in the archive that were extractable from the given zip archive fragment
- $zip_file_names : array<string|int, mixed>
- Stores path/filenames that were discovered in the initial segment of this zip archive
- __construct() : mixed
- Sets up a PartialZipArchive so that files can be extracted from it.
- getFromName() : mixed
- Returns from the PartialZipArchive the uncompressed contents of the provided path/filename if found, and false otherwise.
- getNameIndex() : string
- Returns the file name for the ith file that was extractable from the archive string used in the constructor.
- numFiles() : int
- Returns the total number of files that were detected in the zip archive fragment.
Constants
DEFLATE
ZIP code to indicate compression type is deflate
public
mixed
DEFLATE
= 8
ENHANCED_DEFLATE
ZIP code to indicate compression type is enhanced deflate (4gb barrier passable)
public
mixed
ENHANCED_DEFLATE
= 9
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
public
mixed
LOCAL_FILE_HEADER
= "PK\x03\x04"
NO_COMPRESSION
ZIP code to indicate compression type is no compression used
public
mixed
NO_COMPRESSION
= 0
Properties
$zip_directory
Stores path/filename -> (compression type, compressed file) associations for all files in the archive that were extractable from the given zip archive fragment
public
array<string|int, mixed>
$zip_directory
= []
$zip_file_names
Stores path/filenames that were discovered in the initial segment of this zip archive
public
array<string|int, mixed>
$zip_file_names
= []
Methods
__construct()
Sets up a PartialZipArchive so that files can be extracted from it.
public
__construct(string $zip_string) : mixed
To this it populates the two field variables @see $zip_directory and @see $zip_file_names. 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 just 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
- $zip_string : string
-
a substring of a zip archive file
Return values
mixed —getFromName()
Returns from the PartialZipArchive the uncompressed contents of the provided path/filename if found, and false otherwise.
public
getFromName(string $file_name) : mixed
Parameters
- $file_name : string
-
contains complete path and file_name of afile
Return values
mixed —uncompressed file contents if found and extractable, false otherwise
getNameIndex()
Returns the file name for the ith file that was extractable from the archive string used in the constructor.
public
getNameIndex(int $index) : string
Parameters
- $index : int
-
the number of file want
Return values
string —its corresponding file name
numFiles()
Returns the total number of files that were detected in the zip archive fragment.
public
numFiles() : int
Return values
int —number of files found in archive