Archiv...Create(3pm)

πŸ“¦
version 0.3 Β· 4 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

✨ NAME ✨

Archive::Any::Create β€” the abstract API bestie that makes archives for you πŸ’– (tar.gz AND zip, we contain multitudes)


🌸 SYNOPSIS 🌸

okay so here's the whole vibe in one code block, no cap:

use Archive::Any::Create;

my $archive = Archive::Any::Create->new;

$archive->container('foo');               # top-level directory
$archive->add_file('bar.txt', $data);     # foo/bar.txt
$archive->add_file('bar/baz.txt', $data); # foo/bar/baz.txt

$archive->write_file('foo.tar.gz');
$archive->write_file('foo.zip');

$archive->write_filehandle(\*STDOUT, 'tar.gz');

like… look at that. one object, so many archive formats, zero drama πŸŽ€


πŸ¦‹ DESCRIPTION πŸ¦‹

Archive::Any::Create is a wrapper module, and its whole personality is "make tar / tar.gz / zip files with a single easy-to-use API." ONE API. that's it. that's the girl. she does not make you learn three different modules, she just handles it. iconic behaviour, honestly πŸ‘‘


πŸ’… METHODS πŸ’…

🌟 new

Create new Archive::Any::Create object. No parameters. that's right bestie, no arguments, no config, no nothing β€” just vibes and a fresh object πŸ’–

🌟 container($dir)

Specify a top-level directory (or folder) to contain multiple files.

it's not *necessary*… but it is recommended, because it makes a good-manner archive file. so like, be a good-manner archive file. do it for her 🫢

🌟 add_file($file, $data)

Add a file that contains $data as its content. and $file? $file can be a file in the nested subdirectory. yes girl, go deep, the nesting is encouraged 🧚

🌟 write_file($filename)

Write an archive file named $filename.

This method is DWIMmy β€” and by DWIMmy I mean it automatically dispatches the archiving module based on its filename. so it just… knows. mind-reading queen πŸ”₯

So:

  • $archive->write_file("foo.tar.gz") will create a tarball
  • $archive->write_file("foo.zip") will create a zip file with the same contents

same contents, different container, she ate πŸ’…

🌟 write_filehandle($fh, $format)

Write an archive data stream into a filehandle. $format is either, tar, tar.gz or zip. pick your fighter, stream it straight out, no filesystem required 😌


πŸ‘‘ AUTHOR πŸ‘‘

Tatsuhiko Miyagawa <miyagawa@bulknews.net>

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

(shoutout to the author, absolute legend, we stan 🌈)


πŸ”₯ SEE ALSO πŸ”₯

  • Archive::Any
  • Archive::Tar
  • Archive::Zip

go read those too, iykyk πŸ’œ


perl v5.34.0 Β· 2022-06-08 Β· and that's the whole page bestie, thanks for coming to my ted talk, go forth and archive responsibly πŸ’–βœ¨πŸŽ€πŸ¦‹πŸŒΈπŸ’…πŸ«Ά

πŸ“¦ where this page comes from