#!/usr/bin/perl
use warnings;
use strict;

use TokyoCabinet;
use Data::Dump qw(dump);

my ($user,$path) = @ARGV;
die "usage: $0 u2001 [path]\n" unless $user;

my $dir = (getpwnam($user))[7];

die "$dir: $!" unless -d $dir;

my $md5 = "$dir/.md5";

die "$md5: $!\n" unless -r $md5;

my %h;
tie %h, "TokyoCabinet::HDB", $md5 || die $!;

if ( $path ) {
	print $h{$path}, "  $path\n";
} else {

	while( my($k,$v) = each(%h) ) {
		$k = "$dir/$k" if $ENV{FULL};
		print "$v  $k\n";
	}

}
