add destination parameter
This commit is contained in:
@@ -539,9 +539,13 @@ function Remove-File ([Parameter(ValueFromPipeline=$true)][string]$path) {
|
||||
}
|
||||
|
||||
# Function to ZIP a file or directory
|
||||
function Zip-Object ([Parameter(ValueFromPipeline=$true)][string]$path) {
|
||||
function Zip-Object {
|
||||
param(
|
||||
[Parameter(ValueFromPipeline=$true)][string]$path,
|
||||
[Parameter(ValueFromPipeline=$false)][string]$dest
|
||||
)
|
||||
If ( $(Get-Item $path) -is [System.IO.DirectoryInfo] ) {
|
||||
$dest = '{0}\{1}.zip' -f $(Split-Path -Parent $path),$(Split-Path -Leaf $path)
|
||||
If ( [string]::IsNullOrEmpty($dest) ) { $dest = '{0}\{1}.zip' -f $(Split-Path -Parent $path),$(Split-Path -Leaf $path) }
|
||||
LogMsg "Creating zip file of: ${path}"
|
||||
Try {
|
||||
Add-Type -Assembly "System.IO.Compression.FileSystem"
|
||||
@@ -566,10 +570,9 @@ function Zip-Object ([Parameter(ValueFromPipeline=$true)][string]$path) {
|
||||
|
||||
# Function to UNZIP a file or directory
|
||||
function Unzip-Object ([Parameter(ValueFromPipeline=$true)][string]$path) {
|
||||
$ext = [System.IO.Path]::GetExtension($path)
|
||||
If ( $ext -eq ".zip" ) {
|
||||
LogMsg "Extracting ""${path}"" to ""${dest}"""
|
||||
If ( [System.IO.Path]::GetExtension($path) -eq ".zip" ) {
|
||||
$dest = Split-Path -Parent $path
|
||||
LogMsg "Extracting ""${path}"" to ""${dest}"""
|
||||
Try {
|
||||
Add-Type -Assembly "System.IO.Compression.FileSystem"
|
||||
[IO.Compression.ZipFile]::ExtractToDirectory($path, $dest)
|
||||
|
||||
Reference in New Issue
Block a user