summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/hashl23
1 files changed, 23 insertions, 0 deletions
diff --git a/bin/hashl b/bin/hashl
index bd0eb6c..0724f9d 100755
--- a/bin/hashl
+++ b/bin/hashl
@@ -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__