Help language development. Donate to The Perl Foundation

Libarchive cpan:CTILMES last updated on 2019-07-08

use Test;
use Libarchive::Write;
use Libarchive::Read;

plan 2;

my $content = "This is some content\n";

my Supplier::Preserving $supplier .= new;

subtest 'write archive',
    plan 3;

    isa-ok my $archive =$supplier,
                                        format => 'paxr',
                                        filter => 'gzip'),
        Libarchive::Write, 'open writer';

    ok $archive.write('afile', $content), 'Write a file';

    ok $archive.close(), 'close writer';

subtest 'read archive',
    plan 6;

    isa-ok my $archive =$supplier.Supply),
        Libarchive::Read, 'open reader';

    isa-ok my $file = $,
        Libarchive::Entry::Read, 'read file';

    is $file.pathname, 'afile', 'pathname';
    is $file.size, $content.encode.bytes, 'size';
    is $file.content, $content, 'content';

    ok $archive.close(), 'close reader';