Tclzipfs(3tcl)
π Tclzipfs β Tcl Library Procedures π
okay bestie, sit down, hydrate, because today we're talking about the Tcl Library Procedures page Tclzipfs(3tcl) and it's literally giving "your ZIP files are a whole entire filesystem now" energy. no cap. π¦
β¨ NAME β¨
TclZipfs_AppHook, TclZipfs_Mount, TclZipfs_MountBuffer, TclZipfs_Unmount β handle ZIP files as Tcl virtual filesystems ποΈβ¨
π SYNOPSIS π
const char *
TclZipfs_AppHook(argcPtr, argvPtr)
int
TclZipfs_Mount(interp, zipname, mountpoint, password)
int
TclZipfs_MountBuffer(interp, data, dataLen, mountpoint, copy)
int
TclZipfs_Unmount(interp, mountpoint)
πΈ ARGUMENTS πΈ
int *argcPtr(in) β Pointer to a variable holding the number of command line arguments frommain(). πchar ***argvPtr(in) β Pointer to an array of strings containing the command line arguments tomain().Tcl_Interp *interp(in) β Interpreter in which the ZIP file system is mounted. The interpreter's result gets modified to hold the result or the error message from the script. πconst char *zipname(in) β Name of a ZIP file. Must not beNULLwhen either mounting or unmounting a ZIP. π«const char *mountpoint(in) β Name of a mount point, which must be a legal Tcl file or directory name. May beNULLto query current mount points. π§const char *password(in) β An (optional) password. UseNULLif no password is wanted to read the file.const void *data(in) β A data buffer to mount. The data buffer must hold the contents of a ZIP archive, and must not beNULL. πsize_t dataLen(in) β The number of bytes in the supplied data buffer argument,data.int copy(in) β If non-zero, the ZIP archive in the data buffer will be internally copied before mounting, allowing the data buffer to be disposed onceTclZipfs_MountBufferreturns. If zero, the caller guarantees that the buffer will be valid to read from for the duration of the mount. β οΈ (so like, zero means you are responsible for keeping that memory alive, bestie, no takebacks)
π DESCRIPTION π
TclZipfs_AppHook is a utility function that does the standard application initialization procedures, taking into account available ZIP archives, like so:
- If the current application has a mountable ZIP archive, that archive is mounted under
ZIPFS_VOLUME/appas a read-only Tcl virtual file system (VFS). The value ofZIPFS_VOLUMEcan be retrieved using the Tcl commandzipfs root. π - If a file named
main.tclis located in the root directory of that file system (i.e., atZIPFS_VOLUME/app/main.tclafter the ZIP archive is mounted as described above) it is treated as the startup script for the process. β¨ - If the file
ZIPFS_VOLUME/app/tcl_library/init.tclis present, thetcl_libraryglobal variable in the initial Tcl interpreter is set toZIPFS_VOLUME/app/tcl_library. - If the directory
tcl_librarywas not found in the main application mount, the system will then search for it as either a VFS attached to the application dynamic library, or as a zip archive namedlibtcl_major_minor_patchlevel.zipeither in the present working directory or in the standard Tcl install location. (For example, the Tcl 9.0.2 release would be searched for in a filelibtcl_9_0_2.zip.) That archive, if located, is also mounted read-only. π
On Windows, TclZipfs_AppHook has a slightly different signature, since it uses WCHAR instead of char. As a result, it requires the application to be compiled with the UNICODE preprocessor symbol defined (e.g., via the -DUNICODE compiler flag). πͺ
The result of TclZipfs_AppHook is the full Tcl version with build information (e.g., 9.0.0+abcdef...abcdef.gcc-1002). The function may modify the variables pointed to by argcPtr and argvPtr to remove arguments; the current implementation does not do so, but callers should not assume that this will be true in the future. π
TclZipfs_Mount is used to mount ZIP archives and to retrieve information about currently mounted archives. If mountpoint and zipname are both specified (i.e. non-NULL), the function mounts the ZIP archive zipname on the mount point given in mountpoint. If password is not NULL, it should point to the NUL terminated password protecting the archive. If not under the zipfs file system root, mountpoint is normalized with respect to it. For example, a mount point passed as either mt or /mt would be normalized to //zipfs:/mt, given that ZIPFS_VOLUME as returned by zipfs root is β//zipfs:/β. An error is raised if the mount point includes a drive or UNC volume. On success, interp's result is set to the normalized mount point path. π«Ά
If mountpoint is a NULL pointer, information on all currently mounted ZIP file systems is stored in interp's result as a sequence of mount points and ZIP file names. π
If mountpoint is not NULL but zipfile is NULL, the path to the archive mounted at that mount point is stored as interp's result. The function returns a standard Tcl result code.
TclZipfs_MountBuffer mounts the ZIP archive content data on the mount point given in mountpoint. Both mountpoint and data must be specified as non-NULL. The copy argument determines whether the buffer is internally copied before mounting or not. The ZIP archive is assumed to be not password protected. On success, interp's result is set to the normalized mount point path. π₯
TclZipfs_Unmount undoes the effect of TclZipfs_Mount, i.e., it unmounts the mounted ZIP file system that was mounted from zipname (at mountpoint). Errors are reported in the interpreter interp. The result of this call is a standard Tcl result code. π
β οΈ the way that TclZipfs_AppHook can not be used in stub-enabled extensions. that's just the rules, bestie. π
π¦ SEE ALSO π¦
β KEYWORDS β
compress, filesystem, zip
and that's the whole vibe, babe β this was Tclzipfs(3tcl) from Tcl version 9.0. slay, go mount something. π
β¨π
π¦ where this page comes from
- debian trixie: tcl9.0-doc 9.0.1+dfsg-2
- ubuntu questing: tcl9.0-doc 9.0.2+dfsg-1
- ubuntu resolute: tcl9.0-doc 9.0.3+dfsg-1
- ubuntu stonking: tcl9.0-doc 9.0.4+dfsg-1
- Copyright (c) 2015 Jan Nijtmans <jan.nijtmans@gmail.com>
- Copyright (c) 2015 Christian Werner <chw@ch-werner.de>
- Copyright (c) 2017 Sean Woods <yoda@etoyoc.com>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms