forked from libyal/libvmdk
/
synczlib.ps1
56 lines (46 loc) · 1.34 KB
/
synczlib.ps1
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# Script that synchronizes zlib.
#
# Version: 20150117
function DownloadFile($Url, $Destination)
{
$Client = New-Object Net.WebClient
${Client}.DownloadFile(${Url}, ${Destination})
}
function ExtractZip($Zip, $Destination)
{
$Shell = New-Object -ComObject Shell.Application
$Archive = ${Shell}.NameSpace(${Zip})
$Directory = ${Shell}.Namespace(${Destination})
foreach($FileEntry in ${Archive}.items())
{
${Directory}.CopyHere(${FileEntry})
}
}
$Filename = "${pwd}\zlib128.zip"
if (Test-Path ${Filename})
{
Remove-Item -Path ${Filename} -Force
}
DownloadFile -Url "http://zlib.net/zlib128.zip" -Destination ${Filename}
if (Test-Path "zlib-1.2.8")
{
Remove-Item -Path "zlib-1.2.8" -Force -Recurse
}
# AppVeyor don't seem to support "native ZIP extraction" so we use 7z instead.
$SevenZip = "C:\Program Files\7-Zip\7z.exe"
if (Test-Path ${SevenZip})
{
# PowerShell will raise NativeCommandError if 7z writes to stdout or stderr
# therefore 2>&1 is added and the output is stored in a variable.
# The leading & and single quotes are necessary to compensate for the spaces in the path.
$Output = Invoke-Expression -Command "& 'C:\Program Files\7-Zip\7z.exe' -y x ${Filename} 2>&1"
}
else
{
ExtractZip -Zip ${Filename} -Destination "${pwd}"
}
if (Test-Path "..\zlib")
{
Remove-Item -Path "..\zlib" -Force -Recurse
}
Move-Item "zlib-1.2.8" "..\zlib"