mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-11 17:58:41 +00:00
Added unpack function
This commit is contained in:
parent
f4a8cf7613
commit
4986a5d64e
|
|
@ -45,7 +45,7 @@ class Zip
|
|||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public static function create(array $sources, string $destination, bool $overwrite = true) : bool
|
||||
public static function pack(array $sources, string $destination, bool $overwrite = true) : bool
|
||||
{
|
||||
$destination = str_replace('\\', '/', realpath($destination));
|
||||
|
||||
|
|
@ -91,4 +91,22 @@ class Zip
|
|||
|
||||
return $zip->close();
|
||||
}
|
||||
|
||||
public static function unpack(string $source, string $destination) : bool
|
||||
{
|
||||
$destination = str_replace('\\', '/', realpath($destination));
|
||||
|
||||
if (file_exists($destination)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$zip = new \ZipArchive();
|
||||
if (!$zip->open($destination)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$zip->extractTo($destination);
|
||||
|
||||
return $zip->close();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user