Skip to content

Commit 3ec8694

Browse files
authored
Merge pull request #17 from continuousphp/targz-extractor
use tar command on non-windows systems
2 parents b23b4ab + 2946fe6 commit 3ec8694

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

module/DeployAgent/src/Resource/Archive/Extractor/TarGzExtractor.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,16 @@ class TarGzExtractor implements ExtractorInterface
2929
*/
3030
public function extract(\SplFileInfo $archive, \SplFileInfo $destination)
3131
{
32-
$targz = new \PharData($archive->getPathname());
33-
/** @var \PharData $tar */
34-
$tar = $targz->decompress();
35-
$tar->extractTo($destination->getPathname());
36-
unlink(str_replace('.tar.gz', '.tar', $archive->getPathname()));
32+
if (preg_match('/^win/i', PHP_OS)) {
33+
$targz = new \PharData($archive->getPathname());
34+
/** @var \PharData $tar */
35+
$tar = $targz->decompress();
36+
$tar->extractTo($destination->getPathname());
37+
unlink(str_replace('.tar.gz', '.tar', $archive->getPathname()));
38+
} else {
39+
exec('tar xzf ' . $archive->getPathname() . ' -C ' . $destination->getPathname());
40+
}
41+
3742
return true;
3843
}
3944

0 commit comments

Comments
 (0)