zipfile::encode(n)
β¨ 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
objectNamebut 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
noCompressis 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 π
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
- fedora 43: tcllib 2.0-3.fc43 Β· TCL
- fedora 44: tcllib 2.0-4.fc44 Β· TCL
- nixos 26.05: tcllib 2.0
- nixpkgs unstable: tcllib 2.0
- Copyright (c) 2008-2009 Andreas Kupries
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms