write-zip/bz2/etc improvements

Topics: Developer Forum, User Forum
Developer
Feb 29, 2008 at 12:13 AM
With respect to Write-Zip doesn't preserve dir structure and Adding files to existing Zip with Write-Zip I think these two issues can be solved by implementing write-zip -add (or -append?). Each separate branch of files (with a common root) can be added in separate stages. A -relative parameter provides the root path to strip.

ps c:\> dir c:\logs\1999\*.txt | write-zip -add .\logs.zip -relative c:\logs

this would add:

1999\log1.txt
1999\log2.txt

...to the zip. This should let us build zips with sets of files from different roots. If the relative parameter is omitted, the current directory is used as a root. If the files being added are outside of the current directory, the files could either be added fully qualified (excluding the drive) or maybe we should throw an error. This behaviour could be overridden by supplying a -flat switch which strips all paths. Conflicting files generate warnings and only the first unique file added remains.

Thoughts?
Coordinator
Feb 29, 2008 at 5:15 AM
I think it would be more PowerShelly to implement an Add-Zip cmdlet to allow for the addition of files to an existing zip file. I like the -relativeToPath parameter idea. I would say if paths are being added outside the current dir and the user hasn't specied -relativeTo or -flat then you error. BTW did you fix the file timestamp issue?
Developer
Feb 29, 2008 at 7:18 PM
Hmm. The only problem with Add-Zip is that then you require a New-Zip cmdlet to stay consistent with verbs. This leads to unneccessary complexity in scripts when you don't neccessarily know whether a Zip exists or not. Alternatively I guess we could just make Add-Zip create a new archive if it doesn't exist already, but is that obvious to a user?
Coordinator
Mar 3, 2008 at 4:32 AM
I don't think New-Zip is necessary (or desired). I could live with either Write-Zip -Append (or -Add) or Add-Zip. Your call.
Coordinator
Mar 15, 2008 at 5:36 AM
Do you think you will be able to also fix the 1984 timestamp bug? :-) Also shouldn't Expand-Archive support ShouldProcess (-whatif)?
Developer
Mar 16, 2008 at 1:11 AM
testing a fix for the timestamp bug right now - you'd think it would be a quick fix, but oh no. not my luck. :)

yeah, shouldprocess is a definite.