out-zip, out-gzip, out-bzip2, out-tar

Topics: Developer Forum
Dec 27, 2006 at 7:37 PM
I'll probably be checking in some prelimary code before the end of the week, and was wondering exactly where and how I should put this stuff in. TFS is greek to me...

also, I'm not 100% sure "out" is the correct verb ; I'm torn between "out" and "write".

They takes FileSystemInfo objects as input, not streams or byte[]. I was stuck in a mental loop for a little while over this before I came around to the "powershell" way.

gci -rec -inc *.log | out-tar archive.tar -passthru | out-gzip archive.tgz

it's kind of clumsy, so I'm not sure if I'm still thinking too unix-ey here. I'm toying with the idea of a parameter for removing the original files after they've been archived which might help with the usability.


- Oisin
Dec 27, 2006 at 10:34 PM
IIRC Out would be used when you have PoSH perform formatting on the text before it hits the sink (destination). Write is more direct I think, passing each object directly to the destination without using a formatter. Well at least that is the distinction I made between Out-Clipboard and Write-Clipboard.
Dec 27, 2006 at 10:35 PM
BTW, could you have Out-Zip/Write-Zip accept both a TAR'd file and set of files that haven't been tar'd yet?
Dec 27, 2006 at 10:37 PM
Oh yeah, glad to see you back here. :-)
Dec 28, 2006 at 12:54 AM
the out-* cmdlets make no distinction between files and archive files -- it takes filesysteminfo objects, so yep, you can pipe a tar and/or uncompressed files

out-gzip and out-bzip2 compress a single source only, by-design. Tar and Zip on the other hand, can contain multiple files and directory structures and as such are perfect candidates for Providers also. There are switches for the zip/tar cmdlets to create one archive per input file, or a single archive for all input files.

PS> cd Zip::c:\temp\myzip.zip
PS> dir


- Ois

p.s. and yeah, I think I'm back for a whle. Phew! you've got a lot of stuff in place -- it'll be a week or so before I get a grip on all of this stuff. Especially TFS - I haven't a clue about it.
Dec 28, 2006 at 4:31 AM
Well for the most part TFS is pretty well hidden by the Visual Studio interface. Just checkout and checkin files. Be aware that every so often (say a couple times a week if not every day), you will want to do a Get Recursive on the solution (perhaps even the $/PowerShellCX dir in the Source Control Explorer) to sync up with what has been checked in. Oh yeah, by default, when you checkout a file to edit, TFS does not get the latest version of that file. That works very well most of the time because the state of your workspace isn't upset i.e. if it grabbed the latest you might have to update the whole solution just to get it to build. Feel free to ask TFS questions in this forum as they come up.
Dec 29, 2006 at 9:37 PM
gotcha -- thanks. what was new to me was the bit about a check-out not prompting you to sync with the latest, a la perforce/p4 and others.

- Oisin