repairFile path will truncate the entries in file until there are
only valid entries (if a corrupted entry is found, then the rest of the file
is truncated).
The old file will be copied to path.bak (or path.bak.1, etc… if the file
already exists).
repairFile tries very hard to avoid leaving files in an inconsistent state:
the truncated file is written in a temporary file, which is then moved into
place, similarly copies are performed with moves instead. Still this is not
fully atomic: there are two consecutive moves, so repairFile may, in case
of crash, yield a state where the path.bak file is there but no path is
there anymore, this would require manual intervention.