EBook-Tools

 view release on metacpan or  search on metacpan

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

            close($fh)
                or croak("Failed to close '",$bookmarkfile,"'!");
        }

        $ebook->init_blank(opffile => $$self{opffile},
                           title => $$self{title},
                           author => $$self{author});
        $ebook->add_document($outfile,'text-main');
        $ebook->save;
    }
    return $$self{opffile};
}


=head2 C<unpack_zip()>

Unpacks Zip archives (including ePub files).

=cut

sub unpack_zip :method
{
    my $self = shift;
    my $subname = ( caller(0) )[3];
    debug(2,"DEBUG[",$subname,"]");

    unless($self->{nosave})
    {
        my $cwd = usedir($self->{dir});

        if (which('unzip')) {
            my @syscmd = ( 'unzip', '-q', $cwd . '/' . $self->{file} );
            system(@syscmd);
            system_result($subname,$CHILD_ERROR,@syscmd);
        }
        else {
            my $zip = Archive::Zip->new();
            my $status = $zip->read($cwd.'/'.$self->{file});
            if ($status != AZ_OK) {
                croak($subname,'(): error while parsing zip file "',$self->{file},'" (',$status,')!');
            }

            $status = $zip->extractTree(undef);
            if ($status != AZ_OK) {
                croak($subname,'(): error while extracting zip file "',$self->{file},'" (',$status,')!');
            }
        }
        chdir($cwd);
    }
    return 1;
}


########## PROCEDURES ##########

# No procedures


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

=head1 BUGS AND LIMITATIONS

=over

=item * DRM isn't handled.  Infrastructure to support this via an
external plug-in module may eventually be built, but it will never
become part of the main module for legal reasons.

=item * Unit tests are incomplete

=item * Documentation is incomplete.  Accessors in particular could
use some cleaning up.

=item * Need to implement setter methods for object attributes

=item * Import/extraction/unpacking is currently limited to PalmDoc,
Mobipocket, and eReader.  Extraction from Microsoft Reader (.lit) and
ePub is also eventually planned.  Other formats may follow from there.

=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

=cut

1;
__END__



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