zipfile::encode(n)

πŸ“¦
version 2.0 Β· 2 versions
, in fedora 43, fedora 44, nixos 26.05, nixpkgs unstable

✨ NAME ✨

zipfile::encode β€” bestie we are MAKING zip archives, like, generating them, from scratch, with our own two hands πŸ’–

This is the manual page for zipfile::encode(n), in case the (n) wasn't clueing you in πŸŽ€


🌸 SYNOPSIS 🌸

package require Tcl 8.5 9

package require logger

package require Trf

package require crc32

package require snit

package require zlibtcl

package require fileutil

package require zipfile::encode ?0.5.1?

::zipfile::encode ?objectName?

<encoder> comment: text

<encoder> file: dst owned src ?noCompress?

<encoder> write archive

okay so the ?0.5.1? is optional, the ?objectName? is optional, and <encoder> is whatever you named your lil guy. we move πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

This package hands you a class for generating zip archives. That's it, that's the whole vibe. You make an object, you feed it files, you tell it where to write the archive. Iconic behavior honestly πŸ‘‘


πŸ’œ CLASS API πŸ’œ

::zipfile::encode ?objectName?

The class command constructs encoder instances, aka objects. The result of the command is the fully-qualified name of the instance command β€” that's the handle you're gonna be using for everything else, so maybe hold onto it 🫢

  • If you don't pass an objectName, the class will generate and use an automatic name. no thoughts, head empty, it handles it.
  • If you do pass an objectName but it's not fully qualified, the command gets created in the current namespace. yes, where you're standing. right there. 🌈

πŸŽ€ INSTANCE API πŸŽ€

<encoder> comment: text

This method sets the text of the global comment for the archive. Like a little note to whoever unzips it πŸ₯Ί

  • The result of the method is the empty string. It returns nothing. It gives nothing. It simply does the thing.
  • In case of multiple calls to this method on the same encoder, the data from the last call prevails over all previous texts. so don't get attached to your first comment bestie, she's getting overwritten πŸ’€

<encoder> file: dst owned src ?noCompress?

This method adds a new file to the archive. let's break it down:

  • The contents of the file are found in the filesystem at src.
  • It will be stored in the archive under path dst. (yes, these can be different, that's the whole point, you're renaming on the way in ✨)
  • If the file is declared as owned by the archive, the original file will be deleted when the archive is constructed and written. 🚨 like actually deleted. gone. so only mark things owned if you mean it.
  • If noCompress is set to true, the file will not be compressed on writing.
  • Otherwise (the default), the file is compressed if it is advantageous. it does a vibe check on the compression and only commits if it's worth it 😌
  • The result of the method is an empty string.

<encoder> write archive

This method takes the global comment and all added files, encodes them as a zip archive, and stores the result at path archive in the filesystem. πŸ“¦

  • All added files which were owned by the archive are deleted at this point. this is the moment of truth, bestie.
  • On the issue of ordering: the files are added to the archive in the same order as they were specified via file:. order preserved, as the universe intended. 🌸
  • > Note that this behaviour is new for version 0.4 and higher. Before 0.4 no specific order was documented. It was lexicographically sorted. The change was made to support zip-based file formats which require a specific order of files in the archive, for example .epub. πŸ”₯ so if you're on old tcllib, your epub was lowkey getting scrambled. not anymore.

🧚 BUGS, IDEAS, FEEDBACK 🧚

This document, and the package it describes, will undoubtedly contain bugs and other problems. (they said it, not me 😭)

Please report such in the category zipfile of the Tcllib Trackers: http://core.tcl.tk/tcllib/reportlist

Please also report any ideas for enhancements you may have for either the package and/or the documentation. they want to hear from you fr fr 🫢

When proposing code changes, please provide unified diffs, i.e the output of diff -u.

Note further that attachments are strongly preferred over inlined patches. Attachments can be made by going to the Edit form of the ticket immediately after its creation, and then using the left-most button in the secondary navigation bar. okay that's very specific but that's literally what it says, do that πŸ’…

⭐ KEYWORDS ⭐

compression, zip


🌈 CATEGORY 🌈

File


Copyright (c) 2008-2009 Andreas Kupries


okay so that's the whole page!! this was zipfile::encode(n) from tcllib, version 0.5.1 β€” shoutout to Andreas Kupries for the 2008-2009 copyright, and shoutout to you for reading all the way to the bottom, main character energy fr πŸ’–βœ¨πŸŽ€πŸ¦‹πŸŒΈπŸ«Ά

πŸ“¦ where this page comes from