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 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] ) {
|
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}"
|
LogMsg "Creating zip file of: ${path}"
|
||||||
Try {
|
Try {
|
||||||
Add-Type -Assembly "System.IO.Compression.FileSystem"
|
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 to UNZIP a file or directory
|
||||||
function Unzip-Object ([Parameter(ValueFromPipeline=$true)][string]$path) {
|
function Unzip-Object ([Parameter(ValueFromPipeline=$true)][string]$path) {
|
||||||
$ext = [System.IO.Path]::GetExtension($path)
|
If ( [System.IO.Path]::GetExtension($path) -eq ".zip" ) {
|
||||||
If ( $ext -eq ".zip" ) {
|
|
||||||
LogMsg "Extracting ""${path}"" to ""${dest}"""
|
|
||||||
$dest = Split-Path -Parent $path
|
$dest = Split-Path -Parent $path
|
||||||
|
LogMsg "Extracting ""${path}"" to ""${dest}"""
|
||||||
Try {
|
Try {
|
||||||
Add-Type -Assembly "System.IO.Compression.FileSystem"
|
Add-Type -Assembly "System.IO.Compression.FileSystem"
|
||||||
[IO.Compression.ZipFile]::ExtractToDirectory($path, $dest)
|
[IO.Compression.ZipFile]::ExtractToDirectory($path, $dest)
|
||||||
|
|||||||
Reference in New Issue
Block a user