Home > security > PAR2 with directory support

PAR2 with directory support

Updated par2cmdline to handle directory structures.

It seems developers lost interest in PAR2 development around year 2004, as I haven’t seen a single new development in the area since. Unfortunately the developers of Quickpar and par2cmdline lost interest in the area before they could deliver directory support for the tools, something which was apparently promised according to forum posts.

Looking at various threads around the internet, it seems quite a few people are still waiting on this feature and since I had a project myself today which needed this functionality, I decided to add a quick fix to one of the existing tools, to give it this capability.

The tool I decided to update was par2cmdline and the update provides the following change in behavior:

  1. Files no longer need to reside in the same directory as the par2-files.
  2. If a directory is provided on the command line when creating a parity set, either explicitly or resolved via a pattern, then its entire structure (contained files and subdirectories) will be added to the parity set.

Just to avoid any confusion; This directory support works for creating, verifying and repairing files. I’m pointing this out because apparently someone made an earlier attempt to address this directory issue, but according to reports only the creation of parity files were extended to handle directories in that effort, not the verification or recovery operations.

So now I’m finally able to create a parity set for all the stuff in my different project directories by simply navigating to them and issuing “par2 c mypar *”

Caveat
Do note that since the various PAR2 tools are presently in such a sad state, with low or no development going on, support for parity sets with directory nested files is likely not to be present in your favorite tool. For example neither the default 0.4 version par2cmdline or QuickPar 0.9.1 have the capability to do anything useful with nested directories. Instead they simply flatten the directory structure internally and start complaining that all the files in the parity set aren’t present in the current directory (directory of the parity-files). So until other tools get corresponding fixes to this problem applied, you’ll have to use this patched program to properly verify and recover directory nested files.

An option without this patched tool is to copy all files into the same directory as the par-files. Then you can at least verify and recover the files using your favorite tool of choice, but then you’d have to copy repaired files back to whatever directory you copied them from.

Patched par2cmdline source and binaries

The source code with my changes is available at GitHub and a windows binary incorporating the fix available here.

Hashes for the binary zip file (par2cmdline-0.4.dir_patch_r1-x86-win32.zip):

  • SHA1:  ACB127AA 9514D09F 87DDE2BD DDCA26C4 470A9F04
  • MD5: 79bbf22880e27635fbc752f1e0962c14

Update: I just found another patched version of the tool, that provides multi-threading. Real nice :)
It claims to be able to add a directory, however I couldn’t figure out how to get it to do that. When I get a bit more time on my hands I’ll see if I can rebase my directory logic in place of that tool’s, as the concurrent threading stuff the author added really does justify using his version as a base, instead of the vanilla version.

Categories: security Tags: , ,
  1. Saint Germain
    July 3, 2012 at 01:51

    Hello,

    I am interested in using your par2 with directory support.
    I have managed to compile it on Debian Testing (I add to change reedsolomon.cpp to add some “template “) but I haven’t managed to make it work.

    It accepts files but not directories:
    par2 c mypar test
    The source file does not exist: /home/user/test

    I’ve managed to make par2_tbb works and it is really an improvement in performance. Would be nice if you could integrate your patch in par2_tbb.

    Thanks,

  2. Saint Germain
    July 3, 2012 at 10:21

    Maybe phpar2 is a better base to rebase your code:
    http://paulhoule.com/phpar2/index.php

  1. No trackbacks yet.

Leave a comment