Skip to content
Tcl Source Code Artifact [4f6bb9d2a7]
Login

Artifact [4f6bb9d2a7]

Artifact 4f6bb9d2a7013164aeb0a2773e7008d36af5b3103efde94f303b2479c61758d2:



CommandName: Tclzipfs ManualSection: 3 Version: 9.0 TclPart: Tcl TclDescription: Tcl Library Procedures Links:

Name

TclZipfs_AppHook, TclZipfs_Mount, TclZipfs_MountBuffer, TclZipfs_Unmount - handle ZIP files as Tcl virtual filesystems

Synopsis

::: {.synopsis} ::: [const char *]{.ret} [TclZipfs_AppHook]{.lit} [argcPtr, argvPtr]{.arg} [int]{.ret} [TclZipfs_Mount]{.lit} [interp, zipname, mountpoint, password]{.arg} [int]{.ret} [TclZipfs_MountBuffer]{.lit} [interp, data, dataLen, mountpoint, copy]{.arg} [int]{.ret} [TclZipfs_Unmount]{.lit} [interp, mountpoint]{.arg} :::

Arguments

.AP "int" *argcPtr in Pointer to a variable holding the number of command line arguments from fBmainfR(). .AP "char" ***argvPtr in Pointer to an array of strings containing the command line arguments to fBmainfR(). .AP Tcl_Interp *interp in Interpreter in which the ZIP file system is mounted. The interpreter's result is modified to hold the result or error message from the script. .AP "const char" *zipname in Name of a ZIP file. Must not be NULL when either mounting or unmounting a ZIP. .AP "const char" *mountpoint in Name of a mount point, which must be a legal Tcl file or directory name. May be NULL to query current mount points. .AP "const char" *password in An (optional) password. Use NULL if no password is wanted to read the file. .AP "const void" *data in A data buffer to mount. The data buffer must hold the contents of a ZIP archive, and must not be NULL. .AP size_t dataLen in The number of bytes in the supplied data buffer argument, fIdatafR. .AP 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 once fBTclZipfs_MountBufferfR returns. If zero, the caller guarantees that the buffer will be valid to read from for the duration of the mount.

Description

TclZipfs_AppHook is a utility function to perform standard application initialization procedures, taking into account available ZIP archives as follows:

  1. If the current application has a mountable ZIP archive, that archive is mounted under fIZIPFS_VOLUMEfRfB/appfR as a read-only Tcl virtual file system (VFS). The value of fIZIPFS_VOLUMEfR can be retrieved using the Tcl command fBzipfs rootfR.

  2. If a file named fBmain.tclfR is located in the root directory of that file system (i.e., at fIZIPFS_VOLUMEfRfB/app/main.tclfR after the ZIP archive is mounted as described above) it is treated as the startup script for the process.

  3. If the file fIZIPFS_VOLUMEfRfB/app/tcl_library/init.tclfR is present, the fBtcl_libraryfR global variable in the initial Tcl interpreter is set to fIZIPFS_VOLUMEfRfB/app/tcl_libraryfR.

  4. If the directory fBtcl_libraryfR was 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 named fBlibtcl_fRfImajorfRfB_fRfIminorfRfB_fRfIpatchlevelfRfB.zipfR either 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 file fBlibtcl_9_0_2.zipfR.) That archive, if located, is also mounted read-only.

On Windows, fBTclZipfs_AppHookfR 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 fB-DUNICODEfR compiler flag).

The result of fBTclZipfs_AppHookfR is the full Tcl version with build information (e.g., fB9.0.0+abcdef...abcdef.gcc-1002fR). The function fImayfR modify the variables pointed to by fIargcPtrfR and fIargvPtrfR to remove arguments; the current implementation does not do so, but callers fIshould notfR 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 fImountpointfR and fIzipnamefR are both specified (i.e. non-NULL), the function mounts the ZIP archive fIzipnamefR on the mount point given in fImountpointfR. If fIpasswordfR is not NULL, it should point to the NUL terminated password protecting the archive. If not under the zipfs file system root, fImountpointfR is normalized with respect to it. For example, a mount point passed as either fBmtfR or fB/mtfR would be normalized to fB//zipfs:/mtfR, given that fIZIPFS_VOLUMEfR as returned by fBzipfs rootfR is "//zipfs:/". An error is raised if the mount point includes a drive or UNC volume. On success, fIinterpfR's result is set to the normalized mount point path.

If fImountpointfR is a NULL pointer, information on all currently mounted ZIP file systems is stored in fIinterpfR's result as a sequence of mount points and ZIP file names.

If fImountpointfR is not NULL but fIzipfilefR is NULL, the path to the archive mounted at that mount point is stored as fIinterpfR's result. The function returns a standard Tcl result code.

TclZipfs_MountBuffer mounts the ZIP archive content fIdatafR on the mount point given in fImountpointfR. Both fImountpointfR and fIdatafR must be specified as non-NULL. The fIcopyfR argument determines whether the buffer is internally copied before mounting or not. The ZIP archive is assumed to be not password protected. On success, fIinterpfR's result is set to the normalized mount point path.

TclZipfs_Unmount undoes the effect of fBTclZipfs_MountfR, i.e., it unmounts the mounted ZIP file system that was mounted from fIzipnamefR (at fImountpointfR). Errors are reported in the interpreter fIinterpfR. The result of this call is a standard Tcl result code.

TclZipfs_AppHook can not be used in stub-enabled extensions.