Skip to content

Instantly share code, notes, and snippets.

@Skyzi000
Last active December 22, 2021 04:08
Show Gist options
  • Save Skyzi000/2c3b8710aea35f0fd7d5f97fdfbda16c to your computer and use it in GitHub Desktop.
Save Skyzi000/2c3b8710aea35f0fd7d5f97fdfbda16c to your computer and use it in GitHub Desktop.
System.IO.Compression.DeflateStreamで圧縮した.deflate拡張子のファイルを放り込むだけでとりあえず展開できるやつ。Windows10上のPowerShell 7.1.2で動作確認した。
param(
[string]$file
)
if ([System.IO.Path]::GetExtension($file) -ne ".deflate") { return; }
$outfile = [System.IO.Path]::Combine([System.IO.Path]::GetDirectoryName($file), [System.IO.Path]::GetFileNameWithoutExtension($file));
try {
$infs = New-Object System.IO.FileStream($file, [System.IO.FileMode]::Open, [System.IO.FileAccess]::Read);
$ds = New-Object System.IO.Compression.DeflateStream($infs, [System.IO.Compression.CompressionMode]::Decompress);
$outfs = New-Object System.IO.FileStream($outfile, [System.IO.FileMode]::CreateNew, [System.IO.FileAccess]::ReadWrite);
$ds.CopyTo($outfs);
}
finally {
$infs.Dispose();
$ds.Dispose();
$outfs.Dispose();
}
Write-Output $outfile;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment