forked from Exafunction/windsurf.vim
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgzip.ps1
More file actions
26 lines (23 loc) · 770 Bytes
/
Copy pathgzip.ps1
File metadata and controls
26 lines (23 loc) · 770 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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
}