mirror of
git://code.qt.io/qt/qt5.git
synced 2026-02-25 00:15:11 +08:00
Change-Id: I5cf59322f5a34cffe9fe8668755800bccb8cc13a Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
32 lines
1.0 KiB
PowerShell
32 lines
1.0 KiB
PowerShell
function Verify-Checksum
|
|
{
|
|
Param (
|
|
[string]$File=$(throw("You must specify a filename to get the checksum of.")),
|
|
[string]$Expected=$(throw("Checksum required")),
|
|
[ValidateSet("sha1","md5")][string]$Algorithm="sha1"
|
|
)
|
|
$fs = new-object System.IO.FileStream $File, "Open"
|
|
$algo = [type]"System.Security.Cryptography.$Algorithm"
|
|
$crypto = $algo::Create()
|
|
$hash = [BitConverter]::ToString($crypto.ComputeHash($fs)).Replace("-", "")
|
|
$fs.Close()
|
|
if ($hash -ne $Expected) {
|
|
Write-Error "Checksum verification failed, got: '$hash' expected: '$Expected'"
|
|
}
|
|
}
|
|
|
|
function Extract-Zip
|
|
{
|
|
Param (
|
|
[string]$Source,
|
|
[string]$Destination
|
|
)
|
|
echo "Extracting '$Source' to '$Destination'..."
|
|
|
|
New-Item -ItemType Directory -Force -Path $Destination
|
|
$shell = new-object -com shell.application
|
|
$zipfile = $shell.Namespace($Source)
|
|
$destinationFolder = $shell.Namespace($Destination)
|
|
$destinationFolder.CopyHere($zipfile.Items(), 16)
|
|
}
|