Differences Between: [Versions 310 and 401] [Versions 310 and 402] [Versions 310 and 403]
Implementation of .tar.gz extractor. Handles extraction of .tar.gz files. Do not call directly; use methods in tgz_packer.
Copyright: | 2013 The Open University |
License: | http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
File Size: | 565 lines (21 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
tgz_extractor:: (8 methods):
__construct()
extract()
extract_or_list()
list_files()
process_header()
process_file_block()
start_current_file()
close_current_file()
tgz_extractor_handler:: (3 methods):
tgz_start_file()
tgz_end_file()
tgz_directory()
Class: tgz_extractor - X-Ref
Extracts .tar.gz files (POSIX format).__construct($archivefile) X-Ref |
Constructor. param: stored_file|string $archivefile Moodle file or OS path to archive |
extract(tgz_extractor_handler $handler, file_progress $progress = null) X-Ref |
Extracts the archive. param: tgz_extractor_handler $handler Will be called for extracted files param: file_progress $progress Optional progress reporting return: array Array from archive path => true of processed files |
extract_or_list(tgz_extractor_handler $handler = null, file_progress $progress = null) X-Ref |
Extracts or lists the archive depending on $this->listmode. param: tgz_extractor_handler $handler Optional handler param: file_progress $progress Optional progress reporting |
list_files() X-Ref |
Lists files in the archive, either using the index file (if present), or by basically extracting the whole thing if there isn't an index file. return: array Array of file listing results: |
process_header($block, $handler) X-Ref |
Process 512-byte header block. param: string $block Tar block param: tgz_extractor_handler $handler Will be called for extracted files |
process_file_block($block, tgz_extractor_handler $handler = null) X-Ref |
Processes one 512-byte block of an existing file. param: string $block Data block param: tgz_extractor_handler $handler Will be called for extracted files |
start_current_file($archivepath, $filesize, $mtime,tgz_extractor_handler $handler = null) X-Ref |
Starts processing a file from archive. param: string $archivepath Path inside archive param: int $filesize Size in bytes param: int $mtime File-modified time param: tgz_extractor_handler $handler Will be called for extracted files |
close_current_file($handler) X-Ref |
Closes the current file, calls handler, and sets up data. param: tgz_extractor_handler $handler Will be called for extracted files |
Interface: tgz_extractor_handler - X-Ref
Interface for callback from tgz_extractor::extract.tgz_start_file($archivepath) X-Ref |
Called when the system begins to extract a file. At this point, the handler must decide where on disk the extracted file should be located. This can be a temporary location or final target, as preferred. The handler can request for files to be skipped, in which case no data will be written and tgz_end_file will not be called. param: string $archivepath Path and name of file within archive return: string Location for output file in filesystem, or null to skip file |
tgz_end_file($archivepath, $realpath) X-Ref |
Called when the system has finished extracting a file. The handler can now process the extracted file if required. param: string $archivepath Path and name of file within archive param: string $realpath Path in filesystem (from tgz_start_file return) return: bool True to continue processing, false to abort archive extract |
tgz_directory($archivepath, $mtime) X-Ref |
Called when a directory entry is found in the archive. The handler can create a corresponding directory if required. param: string $archivepath Path and name of directory within archive param: int $mtime Modified time of directory return: bool True if directory was created, false if skipped |