#!/usr/bin/perl -w
use strict;
use Getopt::Long;

use DBIx::FileStore;

main();

sub main {
    $|++;
    GetOptions() || die "fdbcat [FILENAMES]: Doesn't understand options yet.\n";

    my $dbfs = new DBIx::FileStore( );

    die "fdbcat: pass files to cat from DB\n" unless @ARGV;
    for(@ARGV) {
        unless ($dbfs->name_ok($_)) {
            warn "Skipping file named $_\n";
            next;
        }
        eval { $dbfs->_read_blocks_from_db(\&ourprintcallback, $_ ); };
        warn "fdbcat: Error reading $_: $@" if $@;
    }
}

sub ourprintcallback {
    print $_[0];
}

__END__     

=pod
            
=head1 NAME     
            
fdbcat - Like cat, but outputs files from DBIx::FileStore
                    
=head1 SYNOPSIS     
                
% fdbcat file_store_name.txt

# outputs contents of file_store_name.txt to stdout

=head1 AUTHOR
    
Josh Rabinowitz <joshr>
        
=head1 SEE ALSO
        
L<DBIx::FileStore>, L<fdbget>,  L<fdbls>, L<fdbmv>,  L<fdbput>,  L<fdbrm>,  L<fdbstat>,  L<fdbtidy>
        
=cut    

