-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: if unable to run gzip, tries a powershell solution instead. fixes …
- Loading branch information
Will Ehrendreich
authored and
Will Ehrendreich
committed
Oct 9, 2023
1 parent
32dec44
commit 84ed2b2
Showing
2 changed files
with
85 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
Function Expand-File | ||
{ | ||
Param( | ||
$infile, | ||
$outfile = ($infile -replace '\.gz$','') | ||
) | ||
|
||
$in = New-Object System.IO.FileStream $inFile, ([IO.FileMode]::Open), ([IO.FileAccess]::Read), ([IO.FileShare]::Read) | ||
$output = New-Object System.IO.FileStream $outFile, ([IO.FileMode]::Create), ([IO.FileAccess]::Write), ([IO.FileShare]::None) | ||
$gzipStream = New-Object System.IO.Compression.GzipStream $in, ([IO.Compression.CompressionMode]::Decompress) | ||
|
||
$buffer = New-Object byte[](1024) | ||
while($true) | ||
{ | ||
$read = $gzipstream.Read($buffer, 0, 1024) | ||
if ($read -le 0) | ||
{break | ||
} | ||
$output.Write($buffer, 0, $read) | ||
} | ||
|
||
$gzipStream.Close() | ||
$output.Close() | ||
$in.Close() | ||
Remove-Item $infile | ||
} |