Coder Social home page Coder Social logo

archive-simplezip's Introduction

Archive::SimpleZip

Raku (Perl6) module to write Zip archives.

Linux Build MacOS Build Windows Build

Synopsis

use Archive::SimpleZip;

# Create a zip file in the filesystem
my $z = SimpleZip.new: "mine.zip";

# Add a file to the zip archive
$z.add: "/some/file.txt";

# Add multiple files in one step
# the 'add' method will consume anything that is an Iterable
$z.add: @list_of_files;

# change the compression method to STORE
$z.add: 'somefile', :method(Zip-CM-Store);

# add knows what to do with IO::Glob
use IO::Glob;
$z.add: glob("*.c");

# add a file, but call it something different in the zip file
$z.add: "/some/file.txt", :name<better-name>;

# algorithmically rename the files by passing code to the name option
# in this instance chage file extension from '.tar.gz' to ;.tgz'
$z.add: @list_of_files, :name( *.subst(/'.tar.gz' $/, '.tgz') ), :method(Zip-CM-Store);

# when used in a method chain it will accept an Iterable and output a Seq of filenames

# add all files matched by IO::Glob
glob("*.c").dir.$z ;

# or like this
glob("*.c").$z ;

# contrived example
glob("*.c").grep( ! *.d).$z.uc.sort.say;

# Create a zip entry from a string/blob

$z.create(:name<data1>, "payload data here");
$z.create(:name<data2>, Blob.new([2,4,6]));

# Drop a filehandle into the zip archive
my $handle = "/another/file".IO.open;
$z.create("data3", $handle);

# use Associative interface to call 'create' behind the secenes
$z<data4> = "more payload";

# can also use Associative interface to add a file from the filesystem
# just make sure it is of type IO
$z<data5> = "/real/file.txt".IO;

# or a filehandle
$z<data5> = $handle;

# create a directory
$z.mkdir: "dir1";

$z.close;

Description

Simple write-only interface to allow creation of Zip files.

See the full documentation at the end of the file lib/Archive/SimpleZip.rakumod.

Installation

Assuming you have a working Rakudo installation you should be able to install this with zef :

# From the source directory

zef install .

# Remote installation

zef install Archive::SimpleZip

Support

Suggestions/patches are welcome at Archive-SimpleZip

License

Please see the LICENSE file in the distribution

(C) Paul Marquess 2016-2023

archive-simplezip's People

Contributors

lizmat avatar pmqs avatar zoffixznet avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar

archive-simplezip's Issues

zef install error

Hi,
Got this error message while trying to install from zef:

$ zef install Archive::SimpleZip
===> Searching for: Archive::SimpleZip
===> Searching for missing dependencies: CompUnit::Util, Compress::Zlib, Compress::Zlib::Raw
===> Staging CompUnit::Util:ver<0.6.0>
===> Staging [OK] for CompUnit::Util:ver<0.6.0>
===> Staging Compress::Zlib::Raw:ver<1.0.1>
===> Staging [OK] for Compress::Zlib::Raw:ver<1.0.1>
===> Staging Compress::Zlib:ver<1.1.0>
===> Staging [OK] for Compress::Zlib:ver<1.1.0>
===> Staging Archive::SimpleZip:ver<0.8.0>:auth<zef:pmqs>
===> Staging [OK] for Archive::SimpleZip:ver<0.8.0>:auth<zef:pmqs>
===> Testing: CompUnit::Util:ver<0.6.0>
[CompUnit::Util] # Failed test 'all-loaded finds the correct units'
[CompUnit::Util] # at t/01-utils.t line 14
[CompUnit::Util] # You failed 1 test of 17
===> Testing [FAIL]: CompUnit::Util:ver<0.6.0>
Aborting due to test failure: CompUnit::Util:ver<0.6.0> (use --force-test to override)

README: $zip.add instead of $obj.add?

If I read the code correctly, that $zip call is supposed to work, but it doesn't for me, nor does the glob. However, it does the job I need very well! Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.