diff --git a/Deployment/WindowsPowerShell/Modules/CoreFunctions/Ionic.Zip.dll b/Deployment/WindowsPowerShell/Modules/CoreFunctions/Ionic.Zip.dll new file mode 100644 index 0000000..95fa928 Binary files /dev/null and b/Deployment/WindowsPowerShell/Modules/CoreFunctions/Ionic.Zip.dll differ diff --git a/Deployment/WindowsPowerShell/Modules/CoreFunctions/include/Zip.ps1 b/Deployment/WindowsPowerShell/Modules/CoreFunctions/include/Zip.ps1 new file mode 100644 index 0000000..0980da8 --- /dev/null +++ b/Deployment/WindowsPowerShell/Modules/CoreFunctions/include/Zip.ps1 @@ -0,0 +1,69 @@ +[Void] [System.Reflection.Assembly]::LoadFrom("$__ModulePath\Ionic.Zip.dll") + + +Function Compress-Folder { +<# +#> + [CmdLetBinding()] + param ( + [Parameter(Mandatory=$true)] + [String] $Path, + + [String] $ZipFile = "", + + [Switch] $TempFile, + + [Switch] $ContentOnly + ) + + if (-not [IO.Directory]::Exists($Path)) { + Write-LogError "Directory '$Path' not found." + return + } + + if ($TempFile) { + $ZipFile = [IO.Path]::GetTempFileName() + } + + if ($ZipFile -eq "") { + $ZipFile = "$Path.zip" + } + + if ([IO.File]::Exists($ZipFile)) { + [IO.File]::Delete($ZipFile) + } + + $zip = New-Object Ionic.Zip.ZipFile + if ($ContentOnly) { + [Void] $zip.AddDirectory($Path) + } + else { + [Void] $zip.AddDirectory($Path, (Split-Path -Path $Path -Leaf)) + } + $zip.Save($ZipFile) + $zip.Dispose() + + return $ZipFile +} + + +Function Expand-Zip { +<# +#> + [CmdletBinding()] + param ( + [Parameter(Mandatory=$true)] + [String] $Path, + + [String] $Destination + ) + + if (-not [IO.File]::Exists($Path)) { + Write-LogError "File not found '$Path'" + return + } + + $zip = [Ionic.Zip.ZipFile]::Read($Path) + $zip.ExtractAll($Destination, [Ionic.Zip.ExtractExistingFileAction]::OverwriteSilently) + $zip.Dispose() +}