View Full Version : fixgz: ASCII to binary

March 7th, 2005, 01:39 PM
Although not neccessarily vintage, I came upon a small tool today which may be handy in some situations. Like what I did:

I'm migrating from an old server to elsewhere, and had packed all the files into neat tar.gz and similar packages. I used FTP to transfer files from the server to my local computer. When everything was transferred, I ran "rm -f *" on the non-backed up server. Then I realized that all my files, a couple of hundred MB, had been transferred in ASCII mode! Horror!

Were all my files lost forever? Not only would an ASCII transfer convert line breaks, but presumably strip away the 8th bit from the data too. I start looking on Internet for any salvation tool to try, but the initial reports were pessimistic.

Then I came upon GZip's own homepage, http://www.gzip.org/ which has a very simple tool to un-convert line breaks -- fixgz, available both as C source and Windows binary. It was my last resort, and believe me or not, all files appear to be perfectly salvagable only by taking that measure. I'm not sure if it is due to the properties of GZip files or that the FTP server and/or client was clever enough to transfer files as 8-bit text rather than 7-bit ASCII.

I don't know if all files are 100% OK, but much closer to being OK now than right after the transfer. Phew. Maybe it is a good advice for someone else who does a FTP or other transfer blunder..

joe sixpack
March 7th, 2005, 04:25 PM
hmm that is intresting. i could only guess as to what happend or how if fixed it but thats a very handy program i must say!

March 8th, 2005, 02:50 AM
I'm not sure if the ASCII conversion happens in the server side or the client, but either way I think in my case the data was transferred as intact as possible. If bits were stripped all over, the unzip program would complain loudly, and likewise if some "CR" characters (or if it is "LF" characters) were trimmed away by mistake. The only flaw I've found is that some of the tarred (but not gzipped) mp3:s sound a little distorted, but I'm not sure if it is a transfer problem and how forgiving mp3:s are when it comes to damaged data.

joe sixpack
March 8th, 2005, 03:31 AM
im unsure but i think mpegs will still decode even if there is damage
i think it most times comes out as pops,clicks scratchs
if i remember correctly mp3's are incoded in sections/frames/blocks .. whatever
so you can chop a mp3 in a half and it will still play does not need to be whole.... i think

but would'nt the program have told you of invalid crc?
are you using the same program? for instance mp3's sound just fine
on winamp/win2k but sound a little different depending on what player i use in dos

what i do when trasfering files or swaping hdd's is get together what i want
and create a crc32 or md5 index of the files.. i dont tear down the machine
untill i've checked the files once trasfered. and if im not going to reuse
the drive right away i leave it as is so if something goes wrong i can pop
it into a system and get another copy.... but that is best case situation.

i had to transfer two machines in the last 2 days. but everything aokay.
just takes F\/{|<ing forever.