#!/usr/bin/perl
use warnings;
use strict;
-use Digest::SHA1 qw(sha1 sha1_hex sha1_base64);
+use Digest::SHA qw(sha1 sha1_hex sha1_base64);
use Fcntl qw(:DEFAULT :flock);
use File::Compare;
use File::Path;
use File::stat;
use MIME::Base64;
-# Copyright (C) 2010 Zygo Blaxell <dupemerge@mailtoo.hungrycats.org>
+# Copyright (C) 2010-2012 Zygo Blaxell <dupemerge@mailtoo.hungrycats.org>
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
sub digest {
my ($filename) = (@_);
die "'$filename' is not a plain file" if (-l $filename) || ! (-f _);
- my $ctx = Digest::SHA1->new;
+ my $ctx = Digest::SHA->new;
sysopen(FILE, $filename, O_RDONLY|O_NONBLOCK) or die "open: $filename: $!";
binmode(FILE); # FIXME: Necessary? Probably harmless...
$ctx->addfile(\*FILE);
Usage: $0 link-dir
Hashes a NUL-separated list of files on stdin into link-dir.
-Version: 0.20101024
+Version: 0.20120914
USAGE
}
my $surprises = 0;
eval '
- use Digest::SHA1 qw(sha1 sha1_hex sha1_base64);
+ use Digest::SHA qw(sha1 sha1_hex sha1_base64);
';
if ($@) {
- warn "Digest::SHA1: $@\nUsing external md5sum program to generate hashes.\nPlease install Digest::SHA1 (libdigest-sha1-perl)";
+ warn "Digest::SHA: $@\nUsing external md5sum program to generate hashes.\nPlease install Digest::SHA";
eval <<'DIGEST';
sub really_digest {
sub really_digest {
my ($filename) = (@_);
die "'$filename' is not a plain file" if (-l $filename) || ! (-f _);
- my $ctx = Digest::SHA1->new;
+ my $ctx = Digest::SHA->new;
sysopen(FILE, $filename, O_RDONLY|O_NONBLOCK) or die "open: $filename: $!";
binmode(FILE); # FIXME: Necessary? Probably harmless...
$ctx->addfile(\*FILE);
either hashed (if it is below the --skip-hash size threshold) or compared
(if it is above), but never both.
-Version: 0.20120103
+Version: 0.20120914
USAGE
}