diff options
Diffstat (limited to 'bin/hashl')
-rwxr-xr-x | bin/hashl | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -65,6 +65,16 @@ sub hash_file { return sha1_hex($data); } +sub is_in_list { + my ($file) = @_; + my $hash = hash_file($file); + + if (grep { $_->{'hash'} eq $hash } values %{$db}) { + return 1; + } + return 0; +} + sub process_file { my $file = $File::Find::name; @@ -123,6 +133,19 @@ elsif ($action eq 'list') { printf("%s %s\n", $file->{'hash'}, $name); } } +elsif ($action eq 'in-list') { + if ($ARGV[1]) { + exit (!is_in_list($ARGV[1])); + } + else { + while (my $line = <STDIN>) { + chomp $line; + if (!is_in_list($line)) { + say $line; + } + } + } +} __END__ |