This repository has been archived by the owner on Jan 30, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 36
Inprove extaction #38
Labels
Comments
Could you provide a short example to illustrate your use case? I applied your suggested changes to my local branch: diff --git a/src/Compress/Zip.php b/src/Compress/Zip.php
index 9967d2a..5d7ff1f 100644
--- a/src/Compress/Zip.php
+++ b/src/Compress/Zip.php
@@ -184,7 +184,9 @@ class Zip extends AbstractCompressionAlgorithm
*/
public function decompress($content)
{
- $archive = str_replace(['/', '\\'], DIRECTORY_SEPARATOR, realpath($content));
+ if(!empty($content) && !is_array($content)) { $content = [$content]; }
+
+ $archive = str_replace(['/', '\\'], DIRECTORY_SEPARATOR, realpath($this->getArchive()));
if (empty($archive) || !file_exists($archive)) {
throw new Exception\RuntimeException('ZIP Archive not found');
@@ -210,7 +212,7 @@ class Zip extends AbstractCompressionAlgorithm
throw new Exception\RuntimeException($this->errorString($res));
}
- $res = $zip->extractTo($target);
+ $res = $zip->extractTo($target, $content);
if ($res !== true) {
throw new Exception\RuntimeException($this->errorString($res));
} and it caused a number of failures in existing tests
|
Won't work. As the Closing due to inactivity. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Hi,
For my application I nead to extract only one file from my archive. I've seen it's impossible with Zip adapter now. But in local I've modified the Adapter and seems to works.
I have just made this modification:
On line 187
$archive = str_replace(['/', '\\'], DIRECTORY_SEPARATOR, realpath($this->getArchive()));
I've also added this lines
if(!empty($content) && !is_array($content)) { $content = [$content]; }
and finally pass the array to the extrac method.
$res = $zip->extractTo($target, $content);
Of Course it's not the best solution, it's only a test, but maybe you can takes this example for improve the library.
The text was updated successfully, but these errors were encountered: