X-Git-Url: http://git.rot13.org/?p=cloudstore.git;a=blobdiff_plain;f=user-md5sum.pl;h=f7042685d71435d8f0d01388f3f60ea6576709c8;hp=e120037ac1d6acde9d8569d9e21026340eef438e;hb=1af8a6c4eb9976794ce6ce0084d9ac3484022c06;hpb=20e2e59ca7c1c98f51b377270e77272d6bbab99e diff --git a/user-md5sum.pl b/user-md5sum.pl index e120037..f704268 100755 --- a/user-md5sum.pl +++ b/user-md5sum.pl @@ -5,21 +5,27 @@ use strict; use TokyoCabinet; use Data::Dump qw(dump); -my $user = shift @ARGV || die "usage: $0 u2001\n"; +my ($user,$path) = @ARGV; +die "usage: $0 u2001 [path]\n" unless $user; my $dir = (getpwnam($user))[7]; -die $! unless -d $dir; +die "$dir: $!" unless -d $dir; -my $path = "$dir/.md5"; +my $md5 = "$dir/.md5"; -die $! unless -r $path; +die "$md5: $!\n" unless -r $md5; my %h; -tie %h, "TokyoCabinet::HDB", $path || die $!; +tie %h, "TokyoCabinet::HDB", $md5 || die $!; -while( my($k,$v) = each(%h) ) { - $k = "$dir/$k" if $ENV{FULL}; - print "$v $k\n"; -} +if ( $path ) { + print $h{$path}, " $path\n"; +} else { + + while( my($k,$v) = each(%h) ) { + $k = "$dir/$k" if $ENV{FULL}; + print "$v $k\n"; + } +}