unzip

=title class Zef::Service::Shell::unzip
=subtitle An unzip based implementation of the Extractor interface

Synopsis

    use Zef;
    use Zef::Service::Shell::unzip;
    my $unzip = Zef::Service::Shell::unzip.new;
    # Assuming a zef-main.zip file is in the cwd...
    my $source       = $*HOME.child("zef-main.zip");
    my $extract-to   = $*TMPDIR.child(time);
    my $extracted-to = $unzip.extract($source, $extract-to);
    die "Something went wrong" unless $extracted-to;
    say "Zef META6 from HEAD: ";
    say $extracted-to.child("zef-main/META6.json").slurp;

Description

Extractor class for handling file based URIs ending in .zip using the unzip command.

You probably never want to use this unless its indirectly through Zef::Extract; handling files and spawning processes will generally be easier using core language functionality. This class exists to provide the means for fetching a file using the Extractor interfaces that the e.g. git/tar adapters use.

Methods

method probe

method probe(--> Bool:D)

Returns True if this module can successfully launch the unzip command.

method extract-matcher

method extract-matcher(Str() $uri --> Bool:D) 

Returns True if this module knows how to extract $uri, which it decides based on if $uri is an existing local file and ends with .zip.

method extract

method extract(IO() $archive-file, IO() $extract-to, Supplier :$stdout, Supplier :$stderr --> IO::Path)

Extracts the files in $archive-file to $save-to via the unzip command. A Supplier can be supplied as :$stdout and :$stderr to receive any output.

On success it returns the IO::Path where the data was actually extracted to. On failure it returns Nil.

method ls-files

method ls-files(IO() $archive-file --> Array[Str])

On success it returns an Array of relative paths that are available to be extracted from $archive-file.

The Camelia image is copyright 2009 by Larry Wall. "Raku" is trademark of the Yet Another Society. All rights reserved.