Closed beinnova closed 5 years ago
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 $content
we must provide archive to extract, not entires to extract from archive provided in the options.
Closing due to inactivity.
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.