EBook-Tools

 view release on metacpan or  search on metacpan

lib/EBook/Tools/MSReader.pm  view on Meta::CPAN


    if(!$args{infile})
    {
        debug(1,$subname,"(): no input file specified!");
        return;
    }
    if(! -f $args{infile})
    {
        debug(1,$subname,"(): input file '",$args{infile},"' not found!");
        return;
    }

    find_convertlit();
    find_convertlit_keys();
    croak($subname,"(): convertlit command not specified!\n")
        unless($convertlit_cmd);

    my @convertlit = ($convertlit_cmd);
    my $retval;
    my $keyfile = $args{keyfile} || $convertlit_keys;
    my $outfile = $args{outfile};
    my $dir = $args{dir};

    if($keyfile)
    {
        push(@convertlit,"-k$keyfile");
    }

    push(@convertlit,$args{infile});

    if($outfile && $dir)
    {
        push(@convertlit,"$dir/$outfile");
    }
    elsif($outfile)
    {
        push(@convertlit,$outfile);
    }
    elsif($dir)
    {
        # Expansion into a directory requires a trailing slash
        unless($dir =~ m{(/ | \\) $}x)
        {
            $dir .= '/';
        }
        push(@convertlit,$dir);
    }
    else
    {
        debug(1,$subname,"(): neither output file nor directory specified!");
        return;
    }

    debug(2,"DEBUG: converting lit with '",join(' ',@convertlit),"'");
    $retval = system(@convertlit);
    return $retval;
}

########## END CODE ##########

=head1 BUGS AND LIMITATIONS

=over

=item * All handling happens through ConvertLIT as an external helper.
Native Perl code may eventually be written to handle non-DRMed
extraction.

=item * Unit tests are unwritten

=back

=head1 AUTHOR

Zed Pobre <zed@debian.org>

=head1 LICENSE AND COPYRIGHT

Copyright 2008 Zed Pobre

Licensed to the public under the terms of the GNU GPL, version 2.

ConvertLIT (not included) is copyright 2002, 2003 Dan A. Jackson, and
licensed under the terms of the GNU GPL, version 2 or later.

=cut

1;
__END__



( run in 1.007 second using v1.01-cache-2.11-cpan-39bf76dae61 )