1
0
Fork 0
mirror of https://github.com/sbrl/Pepperminty-Wiki.git synced 2024-11-29 18:33:01 +00:00
Pepperminty-Wiki/docs/ModuleApi/files/core/07-unpack.php.txt

30 lines
824 B
Text
Raw Normal View History

2019-07-05 19:51:51 +00:00
<?php
// If the extra data directory:
// - doesn't exist already
// - has an mtime before that of this file
// ...extract it again
if(!file_exists($paths->extra_data_directory) ||
filemtime(__FILE__) > filemtime($paths->extra_data_directory)) {
if(file_exists($paths->extra_data_directory))
delete_recursive($paths->extra_data_directory, false);
else
mkdir($paths->extra_data_directory, 0700);
touch($paths->extra_data_directory);
$temp_file = tmpfile();
$source = fopen(__FILE__, "r");
fseek($source, __COMPILER_HALT_OFFSET__);
stream_copy_to_stream($source, $temp_file);
$temp_filename = stream_get_meta_data($temp_file)["uri"];
$extractor = new ZipArchive();
$extractor->open($temp_filename);
$extractor->extractTo($paths->extra_data_directory);
$extractor->close();
fclose($temp_file);
}