Fallback to gzip functions when on Windows
parent
c598fdb0f5
commit
7ccb91667f
|
@ -36,15 +36,28 @@ class GzipDownloader extends ArchiveDownloader
|
||||||
|
|
||||||
protected function extract($file, $path)
|
protected function extract($file, $path)
|
||||||
{
|
{
|
||||||
$targetFile = $path . '/' . basename(substr($file, 0, -3));
|
$targetFilepath = $path . DIRECTORY_SEPARATOR . basename(substr($file, 0, -3));
|
||||||
$command = 'gzip -cd ' . escapeshellarg($file) . ' > ' . escapeshellarg($targetFile);
|
|
||||||
|
|
||||||
if (0 === $this->process->execute($command, $ignoredOutput)) {
|
// Try to use gunzip on *nix
|
||||||
return;
|
if (!defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||||
|
$command = 'gzip -cd ' . escapeshellarg($file) . ' > ' . escapeshellarg($targetFilepath);
|
||||||
|
|
||||||
|
if (0 === $this->process->execute($command, $ignoredOutput)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$processError = 'Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput();
|
||||||
|
throw new \RuntimeException($processError);
|
||||||
}
|
}
|
||||||
|
|
||||||
$processError = 'Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput();
|
// Gzip version of PHP has built-in support of gzip functions
|
||||||
throw new \RuntimeException($processError);
|
$archiveFile = gzopen($file, 'rb');
|
||||||
|
$targetFile = fopen($targetFilepath, 'wb');
|
||||||
|
while ($string = gzread($archiveFile, 4096)) {
|
||||||
|
fwrite($targetFile, $string, strlen($string));
|
||||||
|
}
|
||||||
|
gzclose($archiveFile);
|
||||||
|
fclose($targetFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue