mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-21 13:58:42 +00:00
commit
b74f0b18f6
|
|
@ -262,6 +262,11 @@ class Http implements UriInterface
|
|||
{
|
||||
return $this->path;
|
||||
}
|
||||
|
||||
public function getPathOffset() : int
|
||||
{
|
||||
return substr_count($this->rootPath, '/') - 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
|
|
|||
57
Utils/IO/Zip/ArchiveInterface.php
Normal file
57
Utils/IO/Zip/ArchiveInterface.php
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.1
|
||||
*
|
||||
* @category TBD
|
||||
* @package TBD
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link http://orange-management.com
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
namespace phpOMS\Utils\IO\Zip;
|
||||
/**
|
||||
* Archive interface
|
||||
*
|
||||
* @category Framework
|
||||
* @package phpOMS\Utils\IO
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @license OMS License 1.0
|
||||
* @link http://orange-management.com
|
||||
* @since 1.0.0
|
||||
*/
|
||||
interface ArchiveInterface
|
||||
{
|
||||
/**
|
||||
* Create archive.
|
||||
*
|
||||
* @param string[] $sources Files and directories to compress
|
||||
* @param string $destination Output destination
|
||||
* @param bool $overwrite Overwrite if destination is existing
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public static function pack(array $sources, string $destination, bool $overwrite = true) : bool
|
||||
|
||||
/**
|
||||
* Unpack archive.
|
||||
*
|
||||
* @param string $source File to decompress
|
||||
* @param string $destination Output destination
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public static function unpack(string $source, string $destination) : bool;
|
||||
}
|
||||
1
Utils/IO/Zip/Gz.php
Normal file
1
Utils/IO/Zip/Gz.php
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
1
Utils/IO/Zip/Tar.php
Normal file
1
Utils/IO/Zip/Tar.php
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
1
Utils/IO/Zip/TarGz.php
Normal file
1
Utils/IO/Zip/TarGz.php
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
|
|
@ -30,7 +30,7 @@ namespace phpOMS\Utils\IO\Zip;
|
|||
* @link http://orange-management.com
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class Zip
|
||||
class Zip implements ArchiveInterface
|
||||
{
|
||||
|
||||
/**
|
||||
|
|
@ -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