So you downloaded a library you want to use. Let's say it was hosted on Codeplex and git was broken as usual. Just for an example, we'll say it was Microsoft's (rather good) cross-platform C++ REST library, Casablanca.
Yeah, this is based on a true story. From about ten minutes ago.
So git access is b0rked, but you can get a zip of the latest source. Without missing a beat, you
~/src or wherever you like to keep such things, and
You watch eagerly as files spring into life.
A wild prompt appears:
Overwrite readme.txt [nYANh]?
...or something similar. You hit
y, wondering why there's a readme.txt to overwrite. Files zip by... or rather, unzip by... and then you pause.
The zip had no top-level directory, the casablanca source dirs are all jumbled in with your other library dirs.
Don't panic. Bash is your friend.
You still want the casablanca library anyway, so you put it in its place:
$ mkdir casablanca $ cd casablanca $ unzip ~/Downloads/casablanca-longhash.zip
Okay, now you have the files, properly contained. And you can use this to clean up the mess you just made. After you
cd back to
~/src, do this:
for i in `ls casablanca` do rm -rf $i done
It's brutal and unsafe, but if you just overwrote any conflicting filenames, it's not like you're getting those back anyhow.
I've been bitten by poorly-structured archives (never trust a zip!) enough times and forgotten how easily I could have fixed it enough of those times, I figured it warranted a post. Hope it helps somebody.
Oh, and Codeplex is terrible. I really hope Microsoft migrates all of their open source projects to Github, they're definitely in the process.