fixing broken .Z files?
trixter at oldskool.org
Thu Mar 3 15:10:00 CST 2005
Jim Battle wrote:
>> However the question about fixing .Z files still stands - I'm suprised
>> that given how long the format's been around, nobody ever published a
>> utility to attempt to fix corrupt files.
> mostly everything downstream from the failure is going to be lost.
> If the entire tape is compressed as a stream, then things are very bad
> indeed. If the tape image compresses each file individually, then it
> should be possible to skip for a while and find a good new starting point.
.Z is the output of compress, which doesn't inherently seperate data by blocks
(if it did, you could decompress until bad data was found, then skip to the
next block and start over). It does, however, support a complete flush and
rebuild of the dictionary with code 257, so if you had bad data in a .Z file,
you could attempt to skip over it by searching for the next 257 code, then
start over. The drawback to this is, what if some of the mangled data
inadvertently inserts a 257 code? :-) I don't have time to burn, so I won't
code this for you, but anyone versed in LZW/LZ78 compression schemes and C
could probably write a .Z file salvager (especially since the source code for
compress is freely available).
Any compressed format that compresses in a stream (ie where the data is not
arbitrarily blocked or otherwise seperated) is going to have this problem --
anything corrupted will boffo the rest of the file after that point.
Programs like pkzipfix, etc. simply rebuild the archive by skipping the file
with the bad data. If you want real repairs, you need an archiver that
generates parity information and tacks it onto the archive. WinRAR does this,
as does WinRK and a few others.
Jim Leonard (trixter at oldskool.org) http://www.oldskool.org/
Want to help an ambitious games project? http://www.mobygames.com/
Or check out some trippy MindCandy at http://www.mindcandydvd.com/
More information about the cctalk