rhash / RHash

Great utility for computing hash sums
http://rhash.sf.net
BSD Zero Clause License
585 stars 116 forks source link

rfe: --strip-path #231

Open therube opened 1 year ago

therube commented 1 year ago

rfe: --strip-path such that relative paths are used, even when full(er) path is specified on command line

rhash --strip-path -H c:/tmp/rhash/* would return something like:

doc.txt new.txt testdir/file3.txt rather then c:/tmp/rhash/doc.txt c:/tmp/rhash/new.txt c:/tmp/testdir/file3.txt
rhash commented 1 year ago

This feature is hard to design (especially to work the same on Linux and Windows).

  1. The usefulness of the resulting hash file is questionable in the case, when two different directories are passed by command line (and both are stripped from the resulting paths):

    > rhash --strip-path -H c:/dir1/* c:/dir2/*
    dir1_file1.txt
    dir2_file1.txt
    dir2_file2.txt

    Before verifying such file, the user shall copy all files from the hashed directories into one directory.

  2. In Linux/Unix wildcards are expanded by the shell and are passed to RHash already as separate files (not directories), so RHash can't detect from paths with wildcards which directory should be stripped from file paths.

    I think the only way for RHash to work the same on all platforms is to strip only directories passed with recursive option (without wildcards support):

    > rhash --recursive --strip-path -H c:/dir1/ c:/dir2/
    dir1_subdirA/file1.txt
    dir2_subdirA/file1.txt
    dir2_subdirB/file2.txt